首页 > 其他 > 详细

ie 6 position fixed

时间:2014-02-19 01:45:28      阅读:385      评论:0      收藏:0      [点我收藏+]

IE6position:fixed问题解决方案 

2013-11-06 18:25:04|  分类: JS/CSS |  标签:ie6  fixed  |举报 |字号订阅

 
 

普通写法

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

IE6中写法

#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)));
}

不慌,到这里没完,IE6中position:fixed还有一个拖动滚动条的时候闪动的问题,解决方案如下:

IE6中position:fixed闪动

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

 

 

JS的解决方案

 

JS是我最不愿使用的解决方案,因为这种纯样式的bug用JS来解决有点大材小用,而且JS需要DOM载入后才执行,有可能会出现闪屏的现象.

JS的解决方案很简单,通过设置一个top来实现,top是指分页的上边距离document的上边的长度,可以被分解成下面几项(并不是完整的代码)

top = scrollTop + clientHeight - height(分页的高度)

bubuko.com,布布扣

scrollTop和clientHeight分别用来解决上面两个问题,滚动条的滚动会影响到scrollTop,而窗口的变化会影响到clientHeight,所以当这两个事件被触发时必须重置top,于是就形成类似下面的代码,但这段脚本的刷新率会非常高,估计有性能问题.

window.onresize = window.onscroll = function(){
    //reset top
};

ie 6 position fixed

原文:http://www.cnblogs.com/czzblog/p/3554352.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!