十二月 24th, 2009

960gs中浮动清除新变化

前端开发, by army8735.

昨天下了新版本960gs,瞅瞅里面有无新的变化,正巧发现其中.clearfix的新变化:

/* `Clear Floated Elements
----------------------------------------------------------------------------------------------------*/

/* http://sonspring.com/journal/clearing-floats */

.clear {
	clear: both;
	display: block;
	overflow: hidden;
	visibility: hidden;
	width: 0;
	height: 0;
}

/* http://perishablepress.com/press/2009/12/06/new-clearfix-hack */

.clearfix:after {
	clear: both;
	content: ' ';
	display: block;
	font-size: 0;
	line-height: 0;
	visibility: hidden;
	width: 0;
	height: 0;
}

/*
	The following zoom:1 rule is specifically for IE6 + IE7.
	Move to separate stylesheet if invalid CSS is a problem.
*/
* html .clearfix,
*:first-child+html .clearfix {
	zoom: 1;
}

关键在于最后几行的更新,用单独的样式为ie6和ie7设置了hack(应该是zoom:1触发hasLayout),来解决极少数情况下浮动清除的bug。至于争议性的.clearfix到底用不用,则实在是个鱼与熊掌的问题。

Back Top

回复自“960gs中浮动清除新变化”

  1. 请问一下clearfix这个功能是怎么用的在960.gs中

  2. 对于children元素有浮动的情况下,自身的高度会被影响,此时样式名加上clearfix就可以解决。

  1. 没有任何引用。

发表回复

Back Top