我正尝试着向页面中加 javascript。但是在用 ie6 测试时,出现问题:固定定位元素在滚动时有抖动现象。在网上查到的方法是给html加样式background,但是无效啊。该怎么解决呢?求高手解答,谢谢!
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 5 <title>教师研修工作室</title> 6 <script type="text/javascript"> 7 window.onscroll=window.onresize=function(){ 8 var scrollTop=document.documentElement.scrollTop || document.body.scrollTop; 9 var oDivTop=document.getElementById('topMenu'); 10 11 if(window.XMLHttpRequest){ 12 return; 13 } 14 else { 15 oDivTop.style.top=scrollTop+'px'; 16 } 17 }; 18 </script> 19 <style type="text/css"> 20 html { 21 font-family: "微软雅黑", tahoma, arial, \5b8b\4f53, sans-serif; 22 _background: url(about:blank) fixed; 23 /*_text-overflow: ellipsis;*/ 24 } 25 body { 26 color: #444; 27 background-color: #F9F9F9; 28 line-height: 1.5; 29 } 30 body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,p,blockquote,th,td,hr,button,article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section { 31 margin:0;padding:0; 32 } 33 .topmenu { 34 background-color: white; 35 height: 42px; 36 border-top-width: 3px; 37 border-bottom-width: 1px; 38 border-top-style: solid; 39 border-bottom-style: solid; 40 border-top-color: #2CC0FF; 41 border-bottom-color: #E1E1E1; 42 position: fixed; 43 left: 0px; 44 top: 0px; 45 width: 100%; 46 z-index: 5000; 47 _position: absolute; 48 } 49 </style> 50 </head> 51 <body style="height:3000px;"> 52 <div class="topmenu" id="topMenu"></div> 53 </body> 54 </html>
HUWWW
SMILET
相关分类