用css固定div层在页面顶部和底部(兼容IE6)
2013-04-26 16:25
621 查看
这是关于实现css固定div层在页面顶部,css固定div层在页面底部的代码,兼容IE6
有时需要把一个元素固定在页面的某个部位,一般的解决方法是:
<div class="box"></div>
.box{
让元素固定在浏览器的底部和距离右边的10个像素。一般的浏览器都支持这种方法,但是ie6不支持fixed
解决办法:
.box{
}
使元素固定在浏览器的顶部:
使元素固定在浏览器的底部:
这两段代码只能实现在最底部跟最顶部,你可以使用
在ie中你会发现[b]被固定定位的元素在滚动滚动条的时候会闪动[/b]
解决的方法是:
*html{
background-image:url(about:blank); /*使用空背景*/
background-attachment:fixed; /*固定背景*/
}
这样ie6中不支持fixed问题算是解决了。
有时需要把一个元素固定在页面的某个部位,一般的解决方法是:
<div class="box"></div>
.box{
position:fixed;bottom:0;right:10px;}
让元素固定在浏览器的底部和距离右边的10个像素。一般的浏览器都支持这种方法,但是ie6不支持fixed
解决办法:
.box{
osition:fixed; _position:absolute; bottom:0; right:10px; _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
)))
}
使元素固定在浏览器的顶部:
.box
{ _position:absolute; _bottom:auto; _top:expression(eval(document.documentElement.scrollTop)); }
使元素固定在浏览器的底部:
.
box{ _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))); }
这两段代码只能实现在最底部跟最顶部,你可以使用
_margin-top:10px;或者
_margin-bottom:10px;修改其中的数值控制元素的位置。
在ie中你会发现[b]被固定定位的元素在滚动滚动条的时候会闪动[/b]
解决的方法是:
*html{
background-image:url(about:blank); /*使用空背景*/
background-attachment:fixed; /*固定背景*/
}
这样ie6中不支持fixed问题算是解决了。
相关文章推荐
- 用CSS固定DIV层在页面顶部和底部(兼容IE6)
- jQuery&CSS 顶部和底部固定浮动工具栏 兼容IE6 (转)
- 页面元素固定在页面底部的纯css代码(兼容IE6)
- CSS固定DIV,导航条顶部固定fixed(兼容IE6) 推荐
- jQuery&CSS 顶部和底部固定浮动工具栏 兼容IE6
- 兼容IE6的页面底部固定层CSS代码
- CSS问题1:div中 li宽度不固定 ie6和ie7不兼容不自动换行
- div footer标签css实现位于页面底部固定
- 让div始终在页面底部,兼容IE6
- CSS案例,DIV固定在页面底部,不随滚动条的滚动。
- CSS控制DIV永远固定在页面底部不随滚动而滚动
- 纯css实现固定在页面底部的div层
- CSS+DIV固定底部的漂浮导航条(多浏览器兼容)
- CSS Div固定在网页顶部、底部、左侧、右侧
- CSS控制DIV永远固定在页面底部
- css返回顶部图标固定在浏览器右下角且兼容ie6
- CSS制作始终固定页面底部的DIV
- 实现返回顶部按钮一直在页面底部(兼容ie6)
- div+css - Firefox和IE浏览器兼容问题 - padding-right在IE6下导致抖动
- 导航栏固定 和 回到顶部 防抖动兼容ie6