时间:2014-01-29所属栏目: Html+css 来源: 热度:
ie6下,position:fixed不起作用,怎样解决这个bug,以下经实践证明,是可行的。
以底部居右20px为例:
html代码:<div id="bot-fixed"></div>
css代码如下:
1、常规position:fixed 设置
#bot-fixed{position:fixed;bottom:0;right:20px;}
2、ie6下 position:fixed 设置
#bot-fixed{position:fixed;_postion:absolute;bottom:0;_bottom:auto;right:20px;_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));}
3、元素固定在浏览器的顶部和底部设置方法(针对IE6)
A:元素固定在浏览器的顶部:
#bot-fixed{_position:absolute;_bottom:auto;_top:expression(eval(document.documentElement.scrollTop));}
B:元素固定在浏览器的底部:
#bot-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)));}
4、解决position:fixed 层闪烁 的方法
在css样式表中添加*html{ background-image:url(about:blank); background-attachment:fixed; }属性