用伪元素after怎么清除浮动

2025-04-03 23:51:10
推荐回答(2个)
回答1:

.clearfix:after { content: ""; display: block; height: 0; clear: both; visibility: hidden; } .clearfix {*zoom: 1;} /* IE6、7 专有 */
或者:
.clearfix:before,.clearfix:after {
content:"";
display:table;
}
.clearfix:after {
clear:both;
}
.clearfix {
*zoom:1;
}

回答2:

div:after{clear:both}