模拟实现fixed效果
JS模拟fixed效果。如何解决晃动问题。也就是跟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 mark=true,timeID,num=0;;
var setPos=function(){
markf=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;
...全文
相关推荐
CSS实现模拟position的fixed页面定位效果
本篇将详细介绍如何使用 `position: absolute` 来实现类似 `position: fixed` 的页面定位效果。
详解IE6中的position:fixed问题与随滚动条滚动的效果
但在IE6中,由于缺乏对position: fixed的支持,开发者不得不采取一些变通的方法来实现类似效果。
ie6下实现position:fixed效果实例介绍
以下是一个针对IE6实现`position:fixed`效果的实例:```html<!
IE6 fixed的完美解决方案
纯CSS方法指的是不使用JavaScript,仅通过CSS代码来模拟fixed效果。
jQuery仿gmail实现fixed布局的方法
样式部分使用了内联的CSS来设置页面的基本布局,其中body元素的高度被设置为一个非常高的值(2000px),以便于模拟一个较长的页面,方便观察fixed布局的效果。


