将div固定在页面某处 兼容ie6
时间:2014-04-29 22:29:41
收藏:0
阅读:523
一、样式:
1
2
3
4
5
6
7
8 |
<style> body,div{ margin:0; padding:0} .wrap{width:1000px; margin:0 auto} .info{width:1000px; height:40px;background:#f2f2f2; text-align:center; font:normal 14px/40px ‘Microsoft YaHei‘ ; color:#333} *html{background-image:url(about:blank);background-attachment: fixed } /*ie6下去抖动*/ .div-pos-top{position: fixed ;top:0;_position:absolute;_top:expression(eval(document.documentElement.scrollTop));z-index:2000} /*居于页面顶部*/ .div-pos-bottom{position: fixed ;bottom:0; _position:absolute;_top:expression(documentElement.scrollTop+documentElement.clientHeight - this .offsetHeight-0)}<br> /*居于页面底部*/ </style> |
二、html代码:
1
2
3
4 |
<div class = "wrap" > <div class = "div-pos-top" ><div class = "info" >我固定在页面顶部</div></div> <div class = "div-pos-bottom" ><div class = "info" >我固定在页面底部</div></div> </div> |
评论(0)