展会信息港展会大全

ie6浏览器不支持position:fixed解决办法
来源:互联网   发布日期:2016-03-25 16:13:37   浏览:3401次  

导读:万恶的ie6浏览器不支持position:fixed,下面我来总结常见的解决ie6浏览器不支持position:fixed办法纯css的解决方法滚动条是body的滚动,固定元素是相对bod...

万恶的ie6浏览器不支持position:fixed,下面我来总结常见的解决ie6浏览器不支持position:fixed办法

纯css的解决方法

滚动条是body的滚动,固定元素是相对body定位,那么把它设置窗口那么高,不就一直是在窗口那个位置了?

代码如下

复制代码

html { _overflow: hidden; }

body { _height: 100%; _overflow: auto; }

.box {

position: fixed;

left: 10px;

top: 180px;

_position: absolute;

}

自家用法介绍

代码如下

复制代码

html,html body {background-image:url(about:blank);background-attachment:fixed;}/* 修正IE6不支持position:fixed的bug */

.bottoms{ width:100%; bottombottom:0; position:fixed;_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)));

}

推荐淘宝网用的方法

代码如下

复制代码

*html {/* 只有IE6支持 */

background-image: url(about:blank); /* 使用空背景 */

background-attachment: fixed; /* 固定背景 */

}

#box {

/* 非IE6浏览器使用固定元素 */

position: fixed;

top: 0;

left: 0;

/* IE6改为绝对定位,并通过css表达式根据滚动位置更改top的值 */

_position: absolute;

_top: expression(eval(document.documentElement.scrollTop));

}

赞助本站

人工智能实验室

相关热词: 开发 编程 android

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港