<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.box{
width: 500px;
background-color: antiquewhite;
/* 1.给父盒子一个高度 */
height: 200px;
/* 2.父盒子浮动 */
float: left;
/* 3.父盒子溢出隐藏 */
overflow: hidden;
}
.box>.son{
width: 200px;
height: 200px;
background-color: aqua;
float: left;
}
.box>.son:nth-child(2){
background-color: pink;
}
.clear{
/* 4.添加空盒子 */
clear: both;
}
/* 5.伪元素 内容填充 */
.box::after{
content: '';
/* 转为块状 */
display: block;
clear: both;
}
</style>
</head>
<body>
<div class="box">
<div class="son"></div>
<div class="son"></div>
<div class="clear"></div>
</div>
</body>
</html>
09-08
749