让IE下支持固定定位
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>无标题文档</title> 6 <style> 7 body { 8 _background-image: url(null); /*空背景*/ 9 /*_background-image: url(about:blank);*/ 10 _background-attachment: fixed; /* 固定背景 */ 11 } 12 13 #fixed { 14 position: fixed; 15 top: 50%; /* 非IE下的定位 */ 16 _position: absolute; /*IE6 用absolute模拟fixed*/ 17 _top: expression(document.documentElement.scrollTop + Math.round ( 18 document.documentElement.offsetHeight/ 2)+ "px"); /*IE6 动态top值*/ 19 right: 0; 20 width: 30px; 21 height: 100px; 22 margin-top: -50px; 23 background: #F30; 24 } 25 </style> 26 </head> 27 <body style="height: 3000px;"> 28 <div id="fixed"></div> 29 </body> 30 </html>
1 <style> 2 .box{height:2000px;} 3 .div{width:100px;height:100px;background:red; position:fixed;left:100px;top:100px; _position:absolute;_top:expression(eval(document.documentElement.scrollTop+100)); 4 } 5 </style> 6 </head> 7 <body> 8 <div class="box"> 9 <div class="div"></div> 10 </div>