问题描述
我有一个容器div具有以下属性:
I have a container div with the following attributes:
#cat_container{
margin:0;
padding:5px;
border:1px solid red;
min-height:200px;
}
里面有多个左浮动div。问题是,他们不强制包含div向下扩展,而只是重叠并继续在容器div的边界之外。
Inside there are multiple left floating div's. The problem is that they don't force the containing div to expand downwards, instead just overlapping and continuing outside the container div's boundary.
左浮动div:
.cat_wrap{
border: 1px solid #000;
width:100px;
min-height:120px;
margin:0 10px 5px 0;
padding:0;
float:left;
}
如果我把左边的浮出来,应该做。那么如何让内部div浮动左边,而且还要垂直扩展容器div。
If I take the left float out, the containing div does expand vertically as it should do. So how do I get the inner divs to float left but also expand the container div vertically?
推荐答案
主要div。 overflow:auto;这将强制div容器扩展并适应内容。
you need to set overflow for the main div. overflow: auto; this will force the div container to expand and adapt to the content.
#cat_container{
margin:0;
padding:5px;
border:1px solid red;
min-height:200px;
overflow: auto;
height: auto !important;
}
这篇关于内部左浮动div不会垂直扩展容器div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!