HTML 练习清除浮动 :after

为 clearfix 类所在的 div 内部最后处添加一个 div 标签,内容为 . ,高度为0, 隐藏

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.left{
float: left;
}
.container{
background-color: red;
} .container .item{
width: 180px;
height: 150px;
background-color: #303a40;
border: 1px solid red;
}
.clearfix:after{
content: '.';
display: block;
clear: both;
visibility: hidden;
height: 0;
}
</style>
</head>
<body>
<div class="container clearfix">
<div class="item left"></div>
<div class="item left"></div>
<div class="item left"></div>
<div class="item left"></div>
<div class="item left"></div>
<div class="item left"></div>
<div class="item left"></div>
<div class="item left"></div> </div>
<div>abcd</div>
</body>
</html>
上一篇:【故障处理】 DBCA建库报错CRS-2566


下一篇:javascript获取年月日