解决ie6不支持固定定位(position:fixed)的方法

来源:赵克立博客 分类: 前端开发 标签:--发布时间:2014-04-29 06:04:39最后更新:2014-04-29 06:04:39浏览:2208
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。o_0。
更新时间:
2014-04-29 06:04:39
温馨提示:
学无止境,技术类文章有它的时效性,请留意文章更新时间,如发现内容有误请留言指出,防止别人"踩坑",我会及时更新文章
示例代码 <div id="top"></div>
使元素固定在浏览器的顶部
#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)/2));
}
 
使元素固定在浏览器的底部
#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)));
    }
这两段代码只能实现在最底部跟最顶部,你可以使用?_margin-top:10px;?或者?_margin-bottom:10px;?修改其中的数值控制元素的位置。

position:fixed; 闪动问题

  现在,问题还没有完全解决。在用了上面的办法后,你会发现:被固定定位的元素在滚动滚动条的时候会闪动。解决闪动问题的办法是在?CSS?文件中加入:
*html{
    background-image:url(about:blank);
    background-attachment:fixed;
    }
  其中?*?是给?IE6 识别的。 到此,IE6 的 position:fixed; 问题已经被解决了。

微信号:kelicom QQ群:215861553 紧急求助须知
Win32/PHP/JS/Android/Python