在使用页面距页面底部200px后,如何向具有固定位置的元素添加类?这是我的首页按钮,我希望将其踩到200px后再放到页脚,直到页面结束。固定位置距离右边和底部50像素。
if (pageheight - 200px) {
$(div1).addClass("top-position");
} else {
$(div1).removeClass("top-position");
}
$(document).scroll(function() {
if ($(document).scrollTop()> 200) {
$(div1).addClass("top-position");
} else {
$(div1).removeClass("top-position");
}
})
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句