1. 程式人生 > >clearfix清除浮動的幾種方法

clearfix清除浮動的幾種方法

clearfix清除浮動
1.
.clear{clear:both;line-height:0;}
缺點:頁面複雜的佈局的話會產生很多空標籤

2.
.clearfix:after{
visibility:hidden;
display:block;
font-size:0;
content:"";
clear:both;
height:0;
}
.clearfix{
*zoom:1;
}

3.
.clearfix:after{
content:"\200B";
display:block;
height:0;
clear:both;
}
.clearfix{
*zoom:1;
}

4.
.clearfix:before,.clearfix:after{
content:"";
display:table;
}
.clearfix:after{
clear:both;
}
.clearfix{
*zoom:1;
}