清除浮动的几种简单方法:万能清除浮动法,clear:both......

方法一:给父级元素添加声明:overflow:hidden;。
例: .wrap{ border:3px solid #000;overflow:hidden;}
.box01{ width:500px; height:500px; background:#F00; float:left;}
.box02{ width:500px; height:500px; background:#09F; float:left;}


方法二:给父级元素添加高度:height 。
此处不举例
方法三:在浮动元素下方添加空div,并声明:{clear:both;height:0;overflow:hidden;}
.wrap{ border:3px solid #000;}

.box01{ width:500px; height:500px; background:#F00; float:left;}

.box02{ width:500px; height:500px; background:#09F; float:left;}
.clear{clear:both; height:0; overflow:hidden;}
方法四:万能清除浮动法
.wrap{ border:3px solid #000;}

.box01{ width:500px; height:500px; background:#F00; float:left;}

.box02{ width:500px; height:500px; background:#09F; float:left;}
.clear:after{content:”.”; display:block; clear:both; height:0; overflow:hidden; visibility:hidden; }
方法四备注:(class:”clear” 添加在父级元素class中: class:”wrap clear”)
总注:给以上四种方法中的父元素添加声明:{zoom:1;} 即可兼容IE6浏览器。
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值