你是如何让position:fixed在IE6中工作的?
来源:互联网 发布:谢谢的网络用语2017 编辑:程序博客网 时间:2024/04/30 09:52
本文所使用的技巧是用了一条Internet Explorer的CSS表达式(expression)。你不可以直接使用该表达式,因为它可能会因为缓存而不更新。解决这一点的最简单的方式是使用eval包裹你的语句。
如何解决“振动”的问题?
显然IE有一个多步的渲染进程。当你滚动或调整你的浏览器大小的时候,它将重置所有内容并重画页面,这个时候它就会重新处理css表达式。这会引起一个丑陋的“振动”bug,在此处固定位置的元素需要调整以跟上你的(页面的)滚动,于是就会“跳动”。
解决此问题的技巧就是使用background-attachment:fixed为body或html元素添加一个background-image。这就会强制页面在重画之前先处理CSS。因为是在重画之前处理CSS,它也就会同样在重画之前首先处理你的CSS表达式。这将让你实现完美的平滑的固定位置元素!
这个方案并不是我提供的。我是在网上的某个地方读到这些的。如果你知道是谁原创了这个方法,请告诉前端观察。
我发现的另外一个小技巧是,你根本无需一个真实的图片!你可以使用一个about:blank替代一个spacer.gif图片,而且它工作的同样出色。
让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+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+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));}
- 你是如何让position:fixed在IE6中工作的?
- ie6的position:fixed
- 【IE6 BUG大全】position:fixed在IE6下的实现
- 让IE6也支持position:fixed
- 完美解决CSS中position为fixed在IE6下无效的bug
- 修正IE6不支持position:fixed的bug
- 修正IE6不支持position:fixed的bug
- IE6下position:fixed的bug解决
- 修正IE6不支持position:fixed的bug
- IE6不支持position:fixed的解决方法
- 修正IE6不支持position.fixed的bug
- 修正IE6不支持position:fixed的bug
- 解决IE6不支持position:fixed的问题
- ie6下不支持position:fixed的解决办法
- 修正IE6不支持position:fixed的bug
- 关于IE6不支持position:fixed的解决办法
- ie6不兼容position:fixed的解决方法
- 打造IE6的position:fixed整理篇
- 如何为IDE注册第三方Silverlight控件
- Too many connections错误的解决办法
- 一个Windows C++的线程类实现
- 数据库的连接问题
- Linux export 命令
- 你是如何让position:fixed在IE6中工作的?
- android中去掉标题栏和状态栏,实现全屏
- 百万数据查询优化技巧三十则(从朋友那转来的)
- 第三章 t-sql程序设计基础 批处理与用户自定义函数
- Zend Framework 项目目录结构
- ArrayList Array List性能比较
- 研究
- 我是清华大学的学生
- javascript面向对象技术基础(一)