文本和图像中的浮动内容框 [css]

发布于 2024-10-21 19:29:51 字数 3055 浏览 2 评论 0原文

我知道这可能是一个简单的问题,但今天早上我的思维不正常!基本上我有一个包含内容的盒子(如内容/概览框),我想用一些文本来浮动它,就像浮动图像一样。现在,以下 CSS 正在执行此操作:

picture of what's moving

您将如何解决此问题?

CSS

#content #info_box {
  width: 230px;
  float: left;
  margin-right: 10px;
  margin-right: 0;
  background: #efefef;
}
#content #info_box #content {
  width: 210px;
  margin: 7px 10px;
}
#content #info_box #content ul {
  list-style-type: none;
  padding: 0px;
  margin: 3px 0px 10px 0px;
}
#content #info_box #content ul li {
  background-image: url(/images/arrow_bullet.png);
  background-repeat: no-repeat;
  background-position: 0px 5px;
  padding-left: 14px;
}
#content #info_box #content #dates { font-size: 14px; }

HTML

    <p>Quisque eget odio ac lectus vestibulum faucibus eget in metus. In pellentesque faucibus vestibulum. Nulla at nulla justo, eget luctus tortor. Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed molestie augue sit amet leo consequat posuere. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin vel ante a orci tempus eleifend ut et magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris, quis sollicitudin sapien justo in libero. Vestibulum mollis mauris enim. Morbi euismod magna ac lorem rutrum elementum. Donec viverra auctor lobortis. Pellentesque eu est a nulla placerat dignissim. Morbi a enim in magna semper bibendum. Etiam scelerisque, nunc ac egestas consequat, odio nibh euismod nulla, eget auctor orci nibh vel nisi. Aliquam erat volutpat. Mauris vel neque sit amet nunc gravida congue sed sit amet purus. Quisque lacus quam, egestas ac tincidunt a, lacinia vel velit. Aenean facilisis nulla vitae urna tincidunt congue sed ut dui. Morbi malesuada nulla nec purus convallis consequat. Vivamus id mollis quam. Morbi ac commodo nulla. In condimentum orci id nisl volutpat bibendum. Quisque commodo hendrerit lorem quis egestas. Maecenas quis tortor arcu.</p>
<div id="info_box">
    <div id="content">
        <b>Job at a glance</b>
        <br>
        <ul>
            <li>This job is an internship</li>
            <li>It pays $7 per hour</li>
            <li>You'll be working 3 hour shifts</li>
        </ul>
        You'll be scheduled to work on:<br>
        <span id="dates">S <b>M</b> <b>T</b> <b>W</b> <b>T</b> <b>F</b> S</span>
    </div>
</div>

I know this is probably a simple question but my mind just isn't working this morning! Basically I have a box with content in it (like a content/at a glance box) and I want to float it with some text like you would float an image. Right now the following CSS is doing this:

picture of what's happening

How would you go about fixing this?

CSS

#content #info_box {
  width: 230px;
  float: left;
  margin-right: 10px;
  margin-right: 0;
  background: #efefef;
}
#content #info_box #content {
  width: 210px;
  margin: 7px 10px;
}
#content #info_box #content ul {
  list-style-type: none;
  padding: 0px;
  margin: 3px 0px 10px 0px;
}
#content #info_box #content ul li {
  background-image: url(/images/arrow_bullet.png);
  background-repeat: no-repeat;
  background-position: 0px 5px;
  padding-left: 14px;
}
#content #info_box #content #dates { font-size: 14px; }

HTML

    <p>Quisque eget odio ac lectus vestibulum faucibus eget in metus. In pellentesque faucibus vestibulum. Nulla at nulla justo, eget luctus tortor. Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed molestie augue sit amet leo consequat posuere. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin vel ante a orci tempus eleifend ut et magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus luctus urna sed urna ultricies ac tempor dui sagittis. In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris, quis sollicitudin sapien justo in libero. Vestibulum mollis mauris enim. Morbi euismod magna ac lorem rutrum elementum. Donec viverra auctor lobortis. Pellentesque eu est a nulla placerat dignissim. Morbi a enim in magna semper bibendum. Etiam scelerisque, nunc ac egestas consequat, odio nibh euismod nulla, eget auctor orci nibh vel nisi. Aliquam erat volutpat. Mauris vel neque sit amet nunc gravida congue sed sit amet purus. Quisque lacus quam, egestas ac tincidunt a, lacinia vel velit. Aenean facilisis nulla vitae urna tincidunt congue sed ut dui. Morbi malesuada nulla nec purus convallis consequat. Vivamus id mollis quam. Morbi ac commodo nulla. In condimentum orci id nisl volutpat bibendum. Quisque commodo hendrerit lorem quis egestas. Maecenas quis tortor arcu.</p>
<div id="info_box">
    <div id="content">
        <b>Job at a glance</b>
        <br>
        <ul>
            <li>This job is an internship</li>
            <li>It pays $7 per hour</li>
            <li>You'll be working 3 hour shifts</li>
        </ul>
        You'll be scheduled to work on:<br>
        <span id="dates">S <b>M</b> <b>T</b> <b>W</b> <b>T</b> <b>F</b> S</span>
    </div>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

稚气少女 2024-10-28 19:29:51

这就是您所追求的:

http://jsfiddle.net/Mutant_Tractor/qfzJ2/1/

您在所有课程开始时都有一个额外的 #content

This is what you are after:

http://jsfiddle.net/Mutant_Tractor/qfzJ2/1/

You had an extra #content at the start of all your classes

反目相谮 2024-10-28 19:29:51

只需在 *#info_box* 中输入 float:right 即可。为什么你在 *#info_box* 中写了两次 margin-left

simply give float:right in the *#info_box*. Why have you written margin-left in *#info_box* two times?

您的好友蓝忘机已上羡 2024-10-28 19:29:51

据我了解,你想将 #info_box 放在 p 的右侧,所以
为 p 指定固定宽度,并将其向左浮动,将 #info_box 向右浮动。

As I understand u want to place the #info_box to the right of p so
give a fixed width for p and float it to left and float the #info_box to the right.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文