IE6下 position:fixed 兼容问题
来源:互联网 发布:韩红 中国好声音 知乎 编辑:程序博客网 时间:2024/05/14 09:59
IE6不支持position:fixed,这个bug与IE6的双倍margin和不支持PNG透明等bug一样臭名昭著。
你是如何让position:fixed在IE6中工作的?
本文所使用的技巧是用了一条Internet Explorer的CSS表达式(expression)。你不可以直接使用该表达式,因为它可能会因为缓存而不更新。解决这一点的最简单的方式是使用eval
包裹你的语句。如何解决“振动”的问题?
显然IE有一个多步的渲染进程。当你滚动或调整你的浏览器大小的时候,它将重置所有内容并重画页面,这个时候它就会重新处理css表达式。这会引起一个丑陋的“振动”bug,在此处固定位置的元素需要调整以跟上你的(页面的)滚动,于是就会“跳动”。
解决此问题的技巧就是使用background-attachment:fixed
为body或html元素添加一个background-image。这就会强制页面在重画之前先处理CSS。因为是在重画之前处理CSS,它也就会同样在重画之前首先处理你的CSS表达式。这将让你实现完美的平滑的固定位置元素!
<span style="font-size:14px;">/*让position:fixed在IE6下可用! */ .fixed-top /* 头部固定 */{position:fixed;bottom:auto;top:0px;}.fixed-bottom /* 底部固定 */{position:fixed;bottom:0px;top:auto;}.fixed-left /* 左侧固定 */{position:fixed;right:auto;left:0px;}.fixed-right /* 右侧固定 */{position:fixed;right:0px;left:auto;}/* 上面的是除了IE6的主流浏览器通用的方法 */* html,* html body /* 修正IE6振动bug */ {background-image:url(about:blank);background-attachment:fixed;}* html .fixed-top /* IE6 头部固定 */ {position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop));}* html .fixed-right /* IE6 右侧固定 */ {position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft</span>
<span style="font-size:14px;">+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||0));} * html .fixed-bottom /* IE6 底部固定 */{position:absolute;bottom:auto;top:expression(eval(document.documentElement.scrollTop </span>
<span style="font-size:14px;">+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));}* html .fixed-left /* IE6 左侧固定 */{position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft));}</span>
0 0
- IE6下 position:fixed 兼容问题
- IE6下实现position:fixed
- IE6下position:fixed;兼容
- IE6下position:fixed的bug解决
- ie6下不支持position:fixed的解决办法
- IE6 fixed 兼容问题
- 解决ie6下position:absolute不兼容问题
- 【IE6 BUG大全】position:fixed在IE6下的实现
- 修复ie6-position:fixed
- position:fixed -------> IE6
- 修复ie6-position:fixed
- IE6 position fixed 解决方法
- ie6的position:fixed
- IE6 position:fixed无效
- IE6 position fixed
- expression解决IE6下固定定位(fixed)的兼容问题
- ie6下不能position:fixed用jquery解决
- 解决IE6浏览器下position:fixed固定定位问题
- Mac OS X必备APP推荐之二
- Android线程的创建与销毁
- error C2664: “CreateWindowExW”: 不能将参数 2 从“const char [11]”转换为“LPCWSTR”
- PHP 类与对象
- TopLevel和Topmost
- IE6下 position:fixed 兼容问题
- URL资源定位器(UniformResourceLocator:URL)
- Android 自定义View (一)
- 用环境变量控制makefile /D选项。从而控制源文件条件编译
- SQL语句 优化
- [LeetCode]101.Symmetric Tree
- VAR
- eclipse-jee-luna-SR1-win32.zip官方下载地址
- 正则表达式模式匹配符