如何最小化漂浮的DIV?

时间:2011-05-10 09:12:56

标签: css xhtml html

我正在尝试将min-height设置为XHTML或HTML文档中的浮动DIV。 将固定高度的DIV放入DIV并用:after清除它的修复根本不起作用。直接分配min-height也不起作用。

我现在的代码就像(在quirks模式下仅适用于Firefox,但我希望它是真实的):

<div style="float:left">
 <div style="float:left; height:200px"><!-- min-height hackfix --></div>
 CONTENT GOES HERE
 <div style="clear:both;"></div>
</div>

2 个答案:

答案 0 :(得分:2)

我没有真正得到你想要的东西,但这里是最小高度问题的修复:

selector {
  min-height:500px;
  height:auto !important;
  height:500px;
}

所以,你的代码可以是这样的

<div style="float:left;min-height:200px;height:auto !important;height:200px;">
     CONTENT GOES HERE
</div>

http://jsfiddle.net/ynhat/pcpsS/1/

答案 1 :(得分:0)

@Cobra;首先关闭您的clear div&amp;而不是clear:both,您可以在父div中编写overflow:hidden

<div style="float:left; overflow:hidden">
 <div style="float:left; height:200px"><!-- min-height hackfix --></div>
 CONTENT GOES HERE
</div>

修改

width:100%提供给您的孩子div。