我有一个div包含3列(每个作为div).问题是父div的高度没有随着列的高度而扩展. 以下是有问题的款式: #content{background: #fff;clear: both;color: #333;padding: 10px 20px 40px 20px;overflow: auto;}#leftcol { p
以下是有问题的款式:
#content{
background: #fff;
clear: both;
color: #333;
padding: 10px 20px 40px 20px;
overflow: auto;
}
#leftcol {
position:absolute;
float:left;
top:285px;
z-index:100;
background-color:#EEEEEE;
padding:5px;
-moz-border-radius: 10px;
border-radius: 10px;
}
#rightcol {
position: absolute;
right:208px;
top:285px;
width:177px;
background-color:#EEEEEE;
padding:5px;
-moz-border-radius: 10px;
border-radius: 10px;
}
#centercol {
margin-left: 288px;
margin-right:200px;
background-color:#EEEEEE;
padding:5px;
-moz-border-radius: 10px;
border-radius: 10px;
}
我认为这是左右列中的绝对定位,这会让事情搞得一团糟.每个不使用列样式的其他页面都可以正常工作.父div的高度随着其内部的扩展而扩展.
有人可以帮帮我吗?
Jonesy
绝对定位的元素从文档流中取出,因此容器div不会“看到”它们.尝试浮动3个div,并添加overflow:auto;到容器div.后者(不是空白’清算’div)是 current best practice.