I tried the solutions here: CSS background-size: cover + background-attachment: fixed clipping background images
and some other places but they don't quite work. The JS solution at the top:
$(window).scroll(function() {
var scrolledY = $(window).scrollTop();
$('#container').css('background-position', 'left ' + ((scrolledY)) + 'px');
});
Is extremely jittery because its repositioning constantly. The other solution (the responsive_calc
one) doesn't work in that I want it centered. The solution always has it left aligned.
I basically want a background-size: cover; but fixed attachment.
JS based solution is fine as long as it doesn't calculate as you scroll.
You can see a demo of the issue here: https://codepen.io/oscargodson/full/abZbZeE
It should look like this
But I get this: