Blog

用clearfix修复float导致的父元素高度塌陷

clearfix

可以给父元素容器加上如下的CSS属性:

.clearfix:after {
  visibility: hidden;
  display: block;
  font-size: 0;
  content: " ";
  clear: both;
  height: 0;
}