Home › Forums › CSS › Using bg-image contain + bg-attachment fixed › Reply To: Using bg-image contain + bg-attachment fixed
September 23, 2015 at 8:18 pm
#208599
Participant
Partial solution found, http://jsfiddle.net/13cf7hd1/
The problem with this snippet is that its geared for background-size: cover
and not for contain
$(window).scroll(function() {
var scrolledY = $(window).scrollTop();
$('#container').css('background-position', 'center ' + ((scrolledY)) + 'px');
});
If you resize the browser window and refresh you’ll see that the background image loads at the bottom correctly, however once you scroll even 1px it quick jumps up farther than the calculated scrolledY
. What’s up with that?