更优雅的清除浮动float方法

上篇文章是利用 :after 方法清除浮动float(作用于浮动元素的父元素上)。

.outer { zoom:1; } //为了兼容性,因为ie6/7不能使用伪类,所以加上此行代码。
.outer:after { clear:both;content:'';display:block;width:0;height:0;visibility:hidden; }

现在可以改写成更优雅的代码:

.outer:before, .outer:after{
    content: "";
    display: table;
}
.outer:after{
    clear: both;
}
原文地址:https://www.cnblogs.com/zhongjiang/p/6440400.html