<!DOCTYPE html>
<html lang="en" dir="ltr"><head><meta charset="utf-8"><title>高度塌陷解决</title><style media="screen">.box1{border: 10px #bfc993 solid;}.box2{width: 100px;height: 100px;background-color: rgb(224, 223, 182);float: left;}.clearfix{zoom:1;}</style></head><body><div class="box1"><div class="box2"></div></div></body>
</html>
效果:设置浮动后父元素高度塌陷
插入下面两段代码:.
clearfix:after{
content: "";display: block;clear: both;}<div class="box1 clearfix">
效果:
本文转载于:猿2048https://www.mk2048.com/blog/blog.php?id=1abhaa&title=解决高度塌陷