CSS高度:auto不能与我的包装器div一起使用

Thr*_*ead 5 html css

我希望有人可以看看我的网站并告诉我这里可能会发生什么.我遇到的问题是#bodyWrap div不会自动伸展到其中一个孩子的高度#contentWrap.#contentWrap可以很好地填充该页面上的所有内容,但这不会冒泡到父对象#bodyWrap.提前感谢您的任何见解.

http://www.jacobsmits.com/placeholderRX/index.html

Mar*_*ein 19

您必须在关闭容器之前添加更清晰的div:

<div style="clear:both;"></div>
Run Code Online (Sandbox Code Playgroud)

浮动项目不会影响容器的高度 ......因为它是浮动的;).

工作实例:http://jsfiddle.net/LBH5h/

示例:

<div id="content">
  <!-- floating child --> <div style="float:left;"><!-- floating child content --></div>

  <div style="clear:both;"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

  • +1谢谢你.这是一个至关重要的重要规则 - "浮动物品不会影响容器的高度". (2认同)