Login

首页 > 收集信息 > jQuery/Js/Css > 正文

解决IE6、IE7、Firefox兼容最简单的CSS Hack --

2012-05-19.Form:互联网

在很多实践中,只用‘修正’1-2个属性就可以了。

#someNode
{
    position: fixed;     <!--Firefox-->
   #position: fixed;   <!--IE7-->
   _position: fixed;  <!--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));
}

 

粤ICP备09089143号