大型网站清除css浮动的最佳方法,例如:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | < 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 > |
清除css浮动的最佳方法:
1 2 | .clearfix:after{ content : " " ; display : block ; height : 0 ; clear : both ; visibility : hidden ;} .clearfix{*+ height : 1% ;} |
原文地址:http://tangjiusheng.com/divcss/23.html