简体   繁体   English

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

[英]CSS height:auto doesn't work with my wrapper div

I was hoping someone can take a look at my site and tell me what may be going on here. 我希望有人可以看看我的网站并告诉我这里可能会发生什么。 The problem I'm having is that the #bodyWrap div is not automatically stretching to the height of one of it's children, #contentWrap. 我遇到的问题是#bodyWrap div不会自动伸展到其中一个孩子的高度#contentWrap。 #contentWrap stretches fine to fill all the content on that page, but this does not bubble up to the parent, #bodyWrap. #contentWrap可以很好地填充该页面上的所有内容,但这不会冒泡到父对象#bodyWrap。 Thanks in advance for any insight. 提前感谢任何见解。

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

You must add a clearer div before your closing containers: 您必须在关闭容器之前添加更清晰的div

<div style="clear:both;"></div>

Floating items won't affect the height of the container ...coz it is floating ;). 浮动项目不会影响容器的高度 ......因为它是浮动的;)。

Working Live Example : http://jsfiddle.net/LBH5h/ 工作实例: http//jsfiddle.net/LBH5h/

Example : 示例:

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

  <div style="clear:both;"></div>
</div>

If something usually won't auto adjust the height for me then I will troubleshoot with these steps. 如果某些东西通常不会自动调整我的高度,那么我将使用这些步骤进行故障排除。

  1. Set the height to something ridiculous (1000px) 将高度设置为荒谬(1000px)
  2. If that make a difference then check all floats 如果这有所不同,那么检查所有浮动
  3. Add a clear:both; 添加一个明确的:两个; statement. 声明。
  4. If it's still not working, add separate border colors to all of your divs. 如果它仍然不起作用,请为所有div添加单独的边框颜色。 It should help you out to see whats setting the height properly and whats messing up the website. 它应该帮助你看看什么是正确设置高度和什么搞乱了网站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM