960 grid的clearfix vs HTML5 Boilerplate的clearfix - 有什么区别?

Joh*_*nny 12 css grid boilerplate clearfix 960.gs

960 grid的clearfix vs HTML5 Boilerplate的clearfix - 有什么区别?

这是Nathan Smith的960网格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;
}
Run Code Online (Sandbox Code Playgroud)

这是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; }
Run Code Online (Sandbox Code Playgroud)

如你所见,它们非常相似.然而他们是不同的.

有没有人对此有任何见解?

哪个更好?为什么?

thi*_*dot 5

唯一的区别是960的内部有.clearfix:before, .clearfix:after:

visibility: hidden;
width: 0;
Run Code Online (Sandbox Code Playgroud)

除此之外,它们是相同的.

height: 0; overflow: hidden 应该删除任何其他声明隐藏伪元素的需要.

我的理论是,HTML5 Boilerplate人员已经严格核实,任何浏览器都不需要这两个额外的声明,然后将它们删除.


Div*_*ian 5

我们的clearfix已更新为:

.clearfix:before, .clearfix:after { content: ""; display: table; }
.clearfix:after { clear: both; }  
.clearfix { zoom: 1; }
Run Code Online (Sandbox Code Playgroud)

Nicolas Gallagher这篇文章中提供了详细信息