开发者

HTML layout help with floating box

What CSS is needed to create such an HTML layout:

+--[li]---------------------------------------------+
|+--[div]-------------------------------------++---+|
|| A label with some text, truncate if necess…||BOX||
|+--------------------------------------------++---+|
|+--[div]------------------------------------------+|
|| Another label, truncate if necessary            ||
|+-------------------------------------------------+|
+---------------------------------------------------+
  • the outer <li> is fixed-width, floating left with the other list items in the list
  • the BOX should float to the right, above the upper <div>, it contains only two letters
  • none of the text in the <div>s should wrap, overflow should be hidden
  • the whole thing 开发者_JS百科should work in IE7 quirks mode, preferably

Currently I have:

<li style="float: left; width: 175px; white-space: nowrap; overflow: hidden;">
  <div style="float: right;">XX</div>
  <div>A label with some text, truncate if necessary</div>
  <div>Another label, truncate if necessary</div>
</li>

But I can't get BOX to hover over the first label.


This happens because right-floated div cannot float around nonwrappable text.

Try this

<li style="float: left; width: 175px; white-space: nowrap; overflow: hidden; position: relative;">
  <div style="position: absolute; right: 0px; background-color: #FFFFFF;">XX</div>
  <div>A label with some text, truncate if necessary</div>
  <div>Another label, truncate if necessary</div>
</li>

if this what you want.


Is this the intended result?

alt text http://img51.imageshack.us/img51/6603/boxf.jpg

<li style="float: left; width: 175px; white-space: nowrap; overflow: hidden;">
  <div style="float: right; position: relative; background-color: red;">BOX</div>
  <div>A label with some text, truncate if necessary</div>
  <div>Another label, truncate if necessary</div>
</li>

Omitting the position: relative, you would get:

alt text http://img360.imageshack.us/img360/7205/box2.jpg


Did you try to float: left the first label?

BTW, Firebug will help you a lot in debugging...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜