<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- 移动端必设置 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
<title>浮动引起的高度塌陷解决方案</title>
<style>
.parent{
border: 1px solid rebeccapurple;
}
.child{
background:burlywood;
width: 200px;
height: 200px;
float: left;
}
.clearFix::before,.clearFix:after{
content:'';
display:table;
clear:both;
}
/*
终极版本同时
(1)解决高度塌陷
(2)外边距重叠问题
.clearFix::before,
.clearFix:after{
content:'';
display:table;
clear:both;
}
*/
</style>
</head>
<body>
<div class="parent clearFix">
<div class="child"></div>
</div>
</body>
</html>
12-29
2692
10-29
411
10-03
1754
10-02
1352