哪个clearfix方法? [英] Which clearfix method?

查看:130
本文介绍了哪个clearfix方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/ * Clear Fix * /

/* Clear Fix */

.clearfix:after {content: ".";display:block;height:0;clear:both;visibility:hidden;}
* html .clearfix {height:1%;}

.clearfix:after {content: ".";display:block;height:0;clear:both;visibility:hidden;}
* html .clearfix, *:first-child+html .clearfix {zoom:1;}

哪个工作最好?
我现在使用第一个,从来没有问题..
感谢。

Which would work the best? I used first one by now and never had an issue.. Thanks.

推荐答案

技巧是设置overflow:为现代浏览器隐藏:

Most succinct technique is setting overflow:hidden for modern browsers:

overflow:hidden;
zoom:1;

如果元素需要流出尺寸(负边距或定位),那么clearfix: p>

If an element needs to flow out of the dimensions ( negative margins or positioning ) then clearfix:

#el:after { content:""; clear:both; display:block; visibility:hidden; }

对于IE6及以下版本,您需要触发hasLayout(通过宽度,缩放:1,height ,和其他属性/值组合)。从IE7开始,溢出将清除浮动。

For IE6 and below, you need to trigger hasLayout ( through a width, zoom:1, height, and other property/value combos ). Starting with IE7, overflow will clear the floats.

这篇关于哪个clearfix方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆