西兰花伟大炮
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.container{
height: auto;
width: 400px;
margin: 100px auto;
border: 2px dotted red;
}
.item{
float: left;
width: 50px;
height: 50px;
background: yellow;
margin-right: 10px;
}
/*.clearfix::after{
content: "";
height: 0;
clear: both;
display: block;
}*/
.last{
clear: both;
}
</style>
</head>
<body>
<div class="container clearfix" >
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="last"></div>
</div>
</body>
</html>两种方法,一种伪类,一种是在末尾添加空元素,欢迎采纳