从我近期网站的统计信息看,IE6的用户还是以60%的比例占有绝对优势的,另外IE7达35%,FIREFOX为2%左右,为此,在设计网页时不得不考虑多浏览器兼容问题,以下是关于这三种主流浏览器的hack兼容方案,很实用哦。
具体写法很容易:
#someNode
{
position: fixed;
#position: fixed;
_position: fixed;
}
* 第一排给Firefox以及其他浏览器看
* 第二排给IE7(可能以后的IE8、IE9也是如此,谁知道呢)看
* 第三排给IE6以及更老的版本看
最好的应用就是可以让IE6也“支持”position:fixed,而且,配合这个原理,可以做到不引入JavaScript代码(仅用IE6的expression),我这里有一个现成的页面,CSS如下写:
#ff-r
{
position: fixed;
_position: absolute;
right: 15px;
top: 15px;
_top: expression(eval(document.compatMode &&
document.compatMode=='CSS1Compat') ?
documentElement.scrollTop+15 :
document.body.scrollTop +
(document.body.clientHeight
-this.clientHeight));
}
是不是很方便?
0 评论:
发表评论