960 grid 的 clearfix 和 HTML5 Boilerplate 的 clearfix - 有什么区别?
这里是 Nathan Smith 的 960 grid 的 css 中所包含的 clearfix:
/* http://www.yuiblog.com/blog/2010/09/27/clearfix-reloaded-overflowhidden-demystified */
.clearfix:before,
.clearfix:after {
content: '\0020';
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}
.clearfix:after {
clear: both;
}
/*
The following zoom:1 rule is specifically for IE6 + IE7.
Move to separate stylesheet if invalid CSS is a problem.
*/
.clearfix {
zoom: 1;
}
这里是Paul Irish的HTML5 Boilerplate中发现的clearfix:
/* The Magnificent Clearfix: Updated to prevent margin-collapsing on child elements.
j.mp/bestclearfix */
.clearfix:before, .clearfix:after {
content: "\0020";
display: block;
height: 0;
overflow: hidden;
}
.clearfix:after { clear: both; }
/* Fix clearfix: blueprintcss.lighthouseapp.com/projects/15318/tickets/5-extra-margin-padding-bottom-of-page */
.clearfix { zoom: 1; }
正如您所看到的,它们非常相似。但是它们是不同的。
有人对此有什么见解吗?
哪个更好,为什么?
.clearfix:after { content: ""; display: table; clear: both; } .clearfix { zoom: 1; }
- Miriam Suzanne