.clearfix::before,
.clearfix::after {
content: ".";
display: block;
height: 0;
visibility: hidden;
}
.clearfix:after {clear: both;}
.clearfix {zoom: 1;}
其实要想清楚.clearfix的浮动,就写下面的代码就足够了
.clearfix::after {
content: ""; //可以是空串,但不能不写
display: block; //只有作为块级元素才能清除浮动
clear:both; //清除左浮动和右浮动,只清除左浮动就写clear:left,右同理
}
display: block;