div是否垂直扩展以适合他们的子div? [英] Do divs expand vertically to fit their children divs?

查看:130
本文介绍了div是否垂直扩展以适合他们的子div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让我的div与他们的子div一起垂直扩展。



我有这样的事情:

 < div class = 'headerWrapper' > 
< div class ='header'>
< img ..... height = 100>
< / div>
< / div>

在萤火虫中,标题div的高度为100,headerWrapper div的高度为0。



图片在它下面的div中可见.... headerWrapper div没有固定的高度。



太混乱了。



感谢 -
Jonathan

解决方案



当一个子元素浮动并且其父元素不存在时,这会导致父元素collapse到0的高度。



页面似乎对页面中途的问题有很好的描述。


I'm having trouble getting my divs to vertically expand with their children divs.

I have something like this:

<div class='headerWrapper'>
    <div class='header'>
        <img..... height=100>
    </div>
</div>

In firebug, the header div has a height of 100, the headerWrapper div has a height of 0.

The image is visible in the div beneath it.... There is no fixed height on the headerWrapper div.

So confused.

Thanks- Jonathan

解决方案

Check and see if you have the header div set to float.

When a child element floats and its parent does not, this causes the parent element to "collapse" to a height of 0.

This page seems to have a pretty good description of the problem about halfway down the page.

这篇关于div是否垂直扩展以适合他们的子div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆