日期:2014-05-16 浏览次数:20433 次
<!doctype html> <html dir="ltr" lang="zh-CN"> <head> <meta charset="utf-8"/> <title>CSS Position Fixed for IE6</title> <style> * html,* html body {background-image:url(about:blank);background-attachment:fixed;} * html .fixed-top {position:absolute;bottom:auto; top:expression(eval(document.documentElement.scrollTop +(document.documentElement.clientHeight-this.offsetHeight)/2 ));} * html .fixed-right {position:absolute;right:0px;left:auto;} * html .fixed-bottom {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)));} * html .fixed-left {position:absolute;right:auto;left:expression(eval(document.documentElement.scrollLeft));} .fixed-bottom { position:fixed; left:0px; bottom:20px; background:aqua; width:200px; height:200px; } .fixed-right{ position:fixed; right:0px; left:auto; top:200px; top:expression(eval(document.documentElement.scrollTop +(document.documentElement.clientHeight-this.offsetHeight)/2 )); background:red; width:200px; height:200px; } .fixed-top{ position:fixed; top:0px; left:0px; background:blue; width:200px; height:200px; } </style> </head> <body> <div style='height:2000px;width:500px;margin:10px auto; border:1px solid red;'></div> <div class="fixed-top"></div> <div class="fixed-bottom"></div> <div class="fixed-right"></div> </body> </html>