1.简介
div浮动,当滚动条下拉时,将div浮动到固定位置上。
2.实现
引用jquery.js略
1.html div加id="float".如
浮动内容
2.css 样式.div2{top:60px;margin-bottom:60px;overflow:hidden;float:left;position:fixed;}
3.js控制functionbuffer(a,b,c){
vard;
returnfunction(){
if(d)return;
d=setTimeout(function(){
a.call(this),
d=undefined
},
b)
}
}(function(){
functione(){
vard=document.body.scrollTop||document.documentElement.scrollTop;
d>b?(a.className="div1div2",c&&(a.style.top=d-b+"px")):a.className="div1"
}
vara=document.getElementById("float");
if(a==undefined)return!1;
varb=0,
c,
d=a;
while(d)b+=d.offsetTop,
d=d.offsetParent;
c=window.ActiveXObject&&!window.XMLHttpRequest;
if(!c||!0)window.onscroll=buffer(e,0,this)
})()