I am trying to recreate a hero section that uses parallax scaled to 150% but the image is using background-attachment: fixed;
this is to not scale the image but to have it move up/down with scroll and the section below it look like it is moving above it when scrolling.
I have the effect working but there is an issue with the background-position
value.
I have it hard coded to background-position: 50% 294px
, the 294px is the value on page load I was getting from the transform property transform: translate3d(0px, -294px, 0p
.
However this value is dynamic and changes depending on screen height and the value entered on scaling which I have at 150%
.
I need to have this value in the background-position property to always be the opposite value that is calculated, since I cannot get 0
to work in the background-position property so that the top of my image is at the top of the section.
Can you tell me how this value is calculated? or recommend a way to always have the at positioned at the top?
Here is a sample of the hero I am trying to reproduce: Hero Parallax