2011-03-15 84 views
0

我知道這可能是一個簡單的問題,但我的頭腦只是今天早上不工作!基本上我有一個包含內容的盒子(比如內容/一瞥盒子),我想用浮動圖像的文本浮動它。現在下面的CSS是這樣做的:浮動內容框中的文字像和圖像[css]

picture of what's happening

你會如何去修復呢?

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> 
+1

'#content #info_box#content'沒有任何意義。這是在ID爲content的元素內尋找一個id爲「content」的元素,其ID爲「info_box」。 – thirtydot 2011-03-15 15:33:55

+0

灰色框在哪裏?在該段的右上角?右上?在左邊? – thirtydot 2011-03-15 15:35:42

+1

Thirtydot,我很想看到需要將標記框顯示在頂部的標記。 ;) – 2011-03-15 15:37:30

回答

1

這是你所追求的:

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

你在所有的類

+0

自己來到同一件事︰http://jsfiddle.net/fdSRU/ – thirtydot 2011-03-15 15:39:54

+0

@thirtydot哈哈快照,偉大的思想...... – 2011-03-15 15:40:24

+0

工作完美!謝謝Myles! – 2011-03-15 16:00:25

1

乾脆放棄在*#* info_box float:right。爲什麼你在*#info_box *中兩次寫入margin-left

+0

由於我使用的網格,這是一個較少的CSS事情。我會嘗試浮動︰對,謝謝:) – 2011-03-15 15:48:32

0

據我瞭解ü要在#info_box地方的右側開始有一個額外的#content p so 給出了一個固定寬度的p,並將它浮動到左側並將#info_box浮動到右側。