yui 中的 grids css 主要有三个部分值得大家关注和学习:
1、布局的思想:使用 “负 margin(negative margins)” 技术
详细可参阅:《creating liquid layouts with negative margins》
2、使用 em :当用户改变字体大小时,宽度同时改变。
技巧:用 13 像素来平分宽度(保留小数到千分位),而 ie 浏览器用 13.333 。
/* 750 centered, and backward compatibility */
#doc {
width:57.69em;
*width:56.251em;
min-width:750px;
}
注:《setting page width with yui grids》 一文中提到:ie 下的 em 是宽度除以 13 ,再乘以 .9759 得到。同解于为什么现在的 yui 源码中 ie 下 750px 的宽度是:56.301em(750 / 13 * 0.9759)。
此算法将在 yui 的下个版本中换为上面的新算法(ie 浏览器用 13.333 )。
3、清除布局的浮动
针对非 ie 浏览器:
.yui-gf:after {
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
而对于 ie 浏览器,使用了 zoom:1 来触发 haslayout。不过对于此 nate koechley 这样解释的:
zoom is a non-valid attribute and so you’ll see warnings when you validate your css. i’m aware of that and think it is an acceptable tradeoff.
个人比较赞成他的想法:i think it is an acceptable tradeoff。
新闻热点
疑难解答