清浮动
父级添加类别!
.clearfix{zoom:1;//兼容ie6,7} .clearfix:after{ content:"."; display: "block"; height: "0"; clear: both; visibility: hidden; }
防止上下margin重叠,也可以清除浮动塌陷(推荐)
.clearfix:after, .clearfix:before{ content:" "; display: table; } .clearfix:after{clear: both;} .clear{ clear:both;}