大型网站清除css浮动的最佳方法
大型网站清除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>
清除css浮动的最佳方法:
.clearfix:after{content:" ";display:block;height:0;clear:both;visibility:hidden;} .clearfix{*+height:1%;}
除注明外的文章,均为来源:老汤博客,转载请保留本文地址!
原文地址:https://tangjiusheng.cn/divcss/23.html
原文地址:https://tangjiusheng.cn/divcss/23.html
大家都在看