Change Background Image Position on Scroll with Jquery
Create a changing scrolling parallax effect with background image scrolling with this jquery code snippet.
1 2 3 4 5 6 7 8 |
$(window).bind("load resize scroll",function(e) { var y = $(window).scrollTop(); $(".parallax-bg-img").filter(function() { return $(this).offset().top < (y + $(window).height()) && $(this).offset().top + $(this).height() > y; }).css('background-position', '0px ' + parseInt(-y / 6) + 'px'); }); |