清除浮动的方法一般有很多种,我们都是根据实际情况或者自己的习惯来清除浮动,最近发现一种比较常用的清除浮动的方法;
.cf:before,
.cf:after {
content: " ";
display: table;
}
.cf:after {
clear: both;
}
/**
* For IE 6/7 only
* Include this rule to trigger hasLayout and contain floats.
*/
.cf {
*zoom: 1;
}
其实主要是利用了:berfore 和:after方法来实现,比起以前的方法简单了一点
本文介绍了一种使用:before和:after伪元素来简化CSS清除浮动的方法。这种方法相较于传统方式更为简洁,适用于多数布局需求。
122

被折叠的 条评论
为什么被折叠?



