JS模拟fixed效果。如何解决晃动问题。也就是跟fixed效果一摸一样。
既然fixed浏览器已经实现,真的就没办法模拟出来吗?!!<div style="width:100%;height:2000px;border:1px red solid;"></div>
<div id="test" style="position:absolute;left:50px;top:0px;background:url(http://avatar.profile.csdn.net/F/4/2/2_gkw521.jpg);width:100px;height:100px;"></div>
<script>
var dom=document.getElementById('test');
var =true,timeID,num=0;;
var setPos=function(){
f=false;
clearInterval(timeID);
timeID=setInterval(function(){
dom.style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-dom.offsetHeight)+'px';
num++;
document.title=num;
//if(num>1000){num=0;clearInterval(timeID);}
},100);
}
setPos();
//window.onscroll=window.onresize=setPos;