css 中的伪类选择器before 与after

.cf:after,.cf:before {content: " "; display: table;}

.cf:after {clear: both;}
:before是因为table类型能生成独立的bfc,防止上边距塌陷,
:after负责清除浮动,防止父级高度塌陷;配合使用,代码少,效率高。


原文地址:https://www.cnblogs.com/leyan/p/6418237.html