- 最后登录
- 2013-7-18
- 注册时间
- 2011-7-16
- 阅读权限
- 70
- 积分
- 3247
 
- 纳金币
- 324742
- 精华
- 0
|
position:fixed在CSS中还是会用到,可是IE6却不支持,用JS来修复,但是滚动时,会晃动。
关于这个问题,我在网上搜索过一段时间,发现一种用CSS的expression方法,虽然这种方法会增加页面读取的计算次数,可是用它来修复IE6固定定位滚动时晃动还是满有效的,也不会因此而影响到其他CSS效果的使用。
用IE6点此查看效果:让IE6支持固定定位且滚动时不晃动。
给标签<div id="fixed"></div>设置样式,如下:
body {
_background-image: url(about:blank); /*用浏览器空白页面作为背景*/
_background-attachment: fixed; /* prevent screen flash in IE6 确保滚动条滚动时,元素不闪动*/
}
#fixed {
position: fixed;
top: 50%; /* 其他浏览器下定位,在这里可设置坐标*/
_position: absolute; /*IE6 用absolute模拟fixed*/
_top: expression(document.documentElement.scrollTop + Math.round(document.documentElement.offsetHeight / 2) + "px"); /*IE6 动态设置top位置*/
background:#f60;
border: 1px solid #f00;
width: 100px;
height: 100px;
margin-left: -50px;
margin-top: -50px;
left: 50%;
} |
|