网站清除css浮动的最佳方法
<html > <head> <title>网站清除css浮动的最佳方法</title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> </head> <body> <style type="text/css"> .clearfix:after{content:" ";display:block;height:0;clear:both;visibility:hidden} .clearfix{*+height:1%;} .box{background:red;width:500px;position:relative;} .left{float:left; background:blue;width:200px; height:100px;} .right{float:right;background:#666;width:200px; height:200px;} .ab{width:100px; height:100px;background:#999;position:absolute;right:-50px;;} </style> <div class="box clearfix"> <div class="l">left</div> <div class="r">right</div> <div class="ab">absolute</div> </div> </body> </html>
最佳方法:
.clearfix:after{content:" ";display:block;height:0;clear:both;visibility:hidden;} .clearfix{*+height:1%;}
评论前必须登录!
注册