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控制function buffer(a, b, c) {
var d;
return function() {
if (d) return;
d = setTimeout(function() {
a.call(this),
d = undefined
},
b)
}
} (function() {
function e() {
var d = document.body.scrollTop || document.documentElement.scrollTop;
d > b ? (a.className = "div1 div2", c && (a.style.top = d - b + "px")) : a.className = "div1"
}
var a = document.getElementById("float");
if (a == undefined) return ! 1;
var b = 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)
})()