上篇文章是利用 :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;
}

 

相关文章:

  • 2021-12-04
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-06-03
猜你喜欢
  • 2021-12-05
  • 2021-12-22
  • 2021-07-20
  • 2022-01-10
相关资源
相似解决方案