.box:after{
content: ".";
display:block;
height:0;
clear:both;
overflow:hidden;
visibility:hidden;
}
.box即是需要解决高度塌陷问题的父元素的类名
本文介绍了一种通过在父元素的类名.box后添加伪元素:after的方法来解决CSS中常见的浮动元素引起的高度塌陷问题。该解决方案利用了clear:both和overflow:hidden等属性,确保了父元素能够正确包含其所有的子浮动元素。
.box:after{
content: ".";
display:block;
height:0;
clear:both;
overflow:hidden;
visibility:hidden;
}
.box即是需要解决高度塌陷问题的父元素的类名
218

被折叠的 条评论
为什么被折叠?