单伪元素跟双伪元素清除浮动方法 课堂笔记

 单伪元素方法:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
    <style>
        .clearfix:after{
                content:"";
                height:0;
                lin-height:0;
                display:block;
                visibility:hidden;
                clear:both;
            }
        .clearfix:after{
                *zoom:1;        /*针对IE6/IE7*/
            }
    </style>
</head>
<body>
	
</body>
</html>

双伪元素方法:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		.clearfix:before,.clearfix:after{
			content:"";
			display:table;
		}
		.clearfix:after{
			clear:both;
		}
		.clearfix:after{
			*zoom:1;
		}
	</style>
</head>
<body>
	
</body>
</html>

猜你喜欢

转载自blog.csdn.net/S_1978P1/article/details/81482486