float时高度塌陷问题

float时高度塌陷问题解决办法:

  • overflow/float/display table inline-block/伪类after{clear:both}等触发BFC的属性以使父容器成为block formatting context roots
  • 在float同级最后方加入带有clear:both属性的元素或伪元素(W3C CSS2.1 9.5.2 clearance高度计算部分)

实现方式

猜你喜欢

转载自blog.csdn.net/itpinpai/article/details/80059635