In my quest to create a unique parallax effect, I am exploring the idea of making each section scroll vertically to unveil the next one, with distinct background colors, images, and text blocks. The challenge lies in keeping the text fixed relative to its parent container while achieving this effect.
To visualize what I aim to achieve, I have created a static example using screenshots for each section: static example. However, my goal is to make the content dynamic rather than relying on flat images.
Below is a simplified version of the code I have written so far:
The parallax effect is implemented through CSS utilizing background-attachment: fixed
, which functions correctly. However, the issue arises with positioning the text blocks. My intention is to have them remain stationary within their respective sections while centered. When set to position: fixed
, the text elements overlap or all display at once in the initial section. Alternatively, any other position attribute causes them to scroll like standard elements.
I understand that setting an element's position to fixed removes its relation to the parent element flow; yet, I am searching for a solution involving advanced CSS techniques or even a JavaScript alternative to accomplish this desired effect.
I have experimented with various HTML/CSS structures and attempted multiple JavaScript solutions such as rellax, jarallax, and ScrollMagic, but these options are too complex for my requirements. Despite dedicating ample time to searching for examples matching my concept, I have been unable to find a suitable one thus far.