当前位置:首页 » CSS » 兼容IE6的fixed定位,解决闪动问题
兼容IE6的fixed定位,解决闪动问题
来自:新思网络时间:2012-07-13 08:56:45

对于非IE6可以这样写


 

    #top{
    position:fixed;
    bottom:0;
    right:20px;
    }

但是IE6是不支持fixed定位的,需要另外重写

    #top{
    position:fixed;
    _position:absolute;
    bottom:0;
    right:20px;
    _bottom:auto;
    _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
    }

使用hack使IE6实现该效果,但是还没有完,这时,这个东东会闪烁,需要以下代码

    *html{
    background-image:url(about:blank);
    background-attachment:fixed;
    }

如果使固定在IE6顶部,使用下面代码

    #top{
    _position:absolute;
    _bottom:auto;
    _top:expression(eval(document.documentElement.scrollTop));
    }

固定在底部使用下面代码

    #top{
    _position:absolute;
    _bottom:auto;
    _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
    }

IE6 这是个爷爷,早应该退伍了!
关键词:兼容IE6,fixed