将div固定在页面某处 兼容ie6
一、样式:
<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)}
/*居于页面底部*/ </style>
二、html代码:
<div class="wrap"> <div class="div-pos-top"><div class="info">我固定在页面顶部</div></div> <div class="div-pos-bottom"><div class="info">我固定在页面底部</div></div> </div>