欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

浮动之清除after伪元素

程序员文章站 2024-01-29 12:46:28
...
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		.clearfix:after{
			content: "";
			display: block;
			height: 0;
			clear:both;
			visibility: hidden;
		}
		.clearfix{*zoom:1;}
		.father{
			background-color: pink;
			width: 600px;
			border: 1px solid #000;
		}
		.bigson{
			float: left;
			width: 200px;
			height: 200px;
			background-color: red;
		}
		.twoson{
			float: left;
			width: 300px;
			height: 300px;
			background-color: yellow;
		}
		.two{
			width: 500px;
			height: 300px;
			background-color: green;
		}
	</style>
</head>
<body>
	<div class="father clearfix">
	<div class="bigson"></div>
	<div class="twoson"></div>
	</div>
	<div class="two"></div>
</body>
</html>

浮动之清除after伪元素