转:jquery 智能浮动定位smartFloat

层的智能浮动效果

$.fn.smartFloat = function () {
var position = function (element) {
console.log(element);
var top = element.position().top, pos = element.css("position");
$(window).scroll(function () {
var scrolls = $(this).scrollTop();
if ((scrolls - 30) > top) {
if (window.XMLHttpRequest) {
element.css({
position: "fixed",
top: 0,
width: "100%",
"background-color": "#FFF",
"z-index":1
});
} else {
element.css({
top: scrolls
});
}
} else {
element.css({
position: pos,
top: top
});
}
});
};
return $(this).each(function () {
position($(this));
});
};

$(".curr-date").parent().smartFloat();

http://www.mamicode.com/info-detail-2149199.html

https://www.zhangxinxu.com/wordpress/2010/11/js%E9%A1%B5%E9%9D%A2%E6%BB%9A%E5%8A%A8%E6%97%B6%E5%B1%82%E6%99%BA%E8%83%BD%E6%B5%AE%E5%8A%A8%E5%AE%9A%E4%BD%8D%E5%AE%9E%E7%8E%B0jquerymootools/

猜你喜欢

转载自www.cnblogs.com/Ly426/p/10277536.html