嗨,当页面一直滚动到底部时,我需要我的背景位置上升 50px。有什么办法吗?
最佳答案
$(window).scroll(function() {
//Checking if scrolled to the bottom
if($(window).scrollTop() + $(window).height() == $(document).height()) {
//Adding background position CSS property to the desired element
$('.YOUR-ELEMENT-CLASS').css('background-position', '0 50px');
}
else {
$('.YOUR-ELEMENT-CLASS').css('background-position', 'default_values');
}
});
关于javascript - 滚动到页面底部时更改背景位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27742788/