div在顶部不变、滚动条滚动,div还是在顶部!直接上传源码了: 方法一: 复制代码 代码如下: div浮层,滚动条移动,保持位置不变 <br>body{background-image:url(about:blank);background-attachment:fixed;}<br>#float{width:344px;height:34px;border:1px solid #C0DBF8;position:absolute;top:0px;}<br> ddd <br>var IO=document.getElementById('float'),Y=IO,H=0,IE6;<br>IE6=window.ActiveXObject&&!window.XMLHttpRequest;<br>while(Y){H =Y.offsetTop;Y=Y.offsetParent};<br>if(IE6)<br> IO.style.cssText="position:absolute;top:(this.fix?(document.documentElement.scrollTop-(this.javascript||" H ")):0)";<br>window.onscroll=function (){<br> var d=document,s=Math.max(d.documentElement.scrollTop,document.body.scrollTop);<br> if(s>H&&IO.fix||s<=H&&!IO.fix)return;<BR> if(!IE6)IO.style.position=IO.fix?"":"fixed"; <BR> IO.fix=!IO.fix;<BR>};<BR>try{document.execCommand("BackgroundImageCache",false,true)}catch(e){};<BR> 方法二: 复制代码代码如下: < ;br> 居中层