网页前端 - 解决IE6不支持position:fixed的问题
前段时间因为公司的某个项目需要用到底部固定元素在网页中随着浏览器滚动而滚动,当然用position:fixed这个属性来做,可是问题来了,IE6.0下面不支持position:fixed这个属性。
在网上查找资料,实践,最终OK了,贴出来大家分享。
当然,在IE6以上版本,火狐,谷歌等浏览器都是件容易的事情,直接用position:fixed这个属性就可以搞定。如:
.top {position:fixed;bottom:auto;top:0px;} /* 头部固定 */
.bottom {position:fixed;bottom:0px;top:auto;} /* 底部固定 */
.left {position:fixed;right:auto;left:0px;} /* 左侧固定 */
.right{position:fixed;right:0px;left:auto;} /* 右侧固定 */
但在IE6及以下版本这样设置是没用的,要设置成这样:
body{background-image:url(about:blank);background-attachment:fixed;} /* 修正IE6振动bug */
.top {position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));} /* IE6 头部固定*/
.left{position:absolute;left:auto;right:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));} /* IE6 右侧固定 */
.right {position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));} /* IE6 右侧固定 */
.bottom {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 底部固定 */
不知道对你有没有帮助呢?
本文地址:http://tuquu.com/tutorial/wd1514.html
-
Macaron 马卡龙系色谱 ;附HC(16进制码)
Macaron 马卡龙系颜色表 色谱/色卡/色表 扩展阅读:马卡龙原指(Macaron
-
@media适配不同尺寸的手机
当下,不同分辨率,不同尺寸的移动设备越来越多,自适应也成了最热门的话题,下面就是图趣网整理到的
-
干货分享!推荐8个高清无水印无版权可商用图
在我们写文章的时候经常需要给文章配一个好图,或者是bannar等等,这就需要我们寻找一些好的无水印
-
国外黄色网站系列欣赏之一
黄色也是一个暖色。它有大自然、阳光、春天的涵义,而且通常被认为是一个快乐和有希望的色彩,黄色
-
CutterMan-一个好用的ps切图插件
cutterman--ps切图工具,方便快捷的用于网页开发/IOS/Android切图功能
-
ps像素图放大边缘模糊?一步搞定
ps像素图放大边缘模糊?我们将分享一个ps无损放大二维码的更方便快捷的实例...
-
庞门正道:好好玩耍的点线面(上)
庞门正道:好好玩耍的点线面(上)
-
经典网页配色方案之无色系
今天跟大家分享无色系配色---指除了彩色以外的其它颜色,常见的有金、银、黑、白、灰。明度从0变化








