<div class="one">
<div class="two"></div>
<div class="three"></div>
</div>
<div class="four"></div>
//css样式设置
.one {
width:1200px;
}
.two {
float:left;
width:500px;
height:500px;
}
.three {
float:right;
width:800px;
height:600px;
}
.four {
width:1200px;
height:200px;
}
//问题描述
这样设置之后.one的高度还是0,而.four是在.two和.three的下面,被遮住了
请问怎么解决?
是因为one没有高度造成的,最直接的办法是设置高度。如果高度不固定
需要用到清除浮动代码:
.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}
.clearfix{*+height:1%;}
给one 增加 class名clearfix
或者,在three下面,增加一个div,class名 clear
.clear{clear:both}