Fix window Screen Js

if ($(".divContentImage").length > 0) {
var offset = $(".divContentImage").offset();
$(window).scroll(function () {
var scrollTop = $(window).scrollTop();
//如果距离顶部的距离小于浏览器滚动的距离,则添加fixed属性。

if (offset.top < scrollTop) {
$(".divContentImage").css({ top: "0px" });
}
else {//否则清除fixed的css属性
//$(".divContentImage").removeClass("fixed");
$(".divContentImage").css({ top: $(".divTitle").offset().top - 1 + "px" });
}
});
}

猜你喜欢

转载自www.cnblogs.com/watchfluture/p/8953033.html