I've achieved the parallaxing background effect a few times before on codepen's and small, experimental projects.
This is my favorite tutorial on it - https://keithclark.co.uk/articles/pure-css-parallax-websites/
Here's the markup from the referenced tutorial:
<div class="parallax">
<div class="parallax__layer parallax__layer--back">
...
</div>
<div class="parallax__layer parallax__layer--base">
...
</div>
</div>
And the vital CSS bits:
.parallax {
...
perspective: 1px;
}
.parallax__layer--base {
transform: translateZ(0);
}
.parallax__layer--back {
transform: translateZ(-1px);
}
Basically - The .parallax element has a perspective, which essentially means it can view things in 3d space.
The .parallax__layer--base(which is the foreground layer) is placed at 0 on the z-axis. So it hasn't moved from it's origin.
The .parallax__layer--back (the background layer) is placed one pixel back on the z axis.
So now, when you scroll through the .parallax element, you can see these background and foreground layers moving in a 3d space, which gives the parallax effect.
But it only works if you are scrolling through the .parallax element - What about on a full-sized, robust page?
<div class='home'>
...
<div class="parallax">
<div class="parallax__layer parallax__layer--back">
...
</div>
<div class="parallax__layer parallax__layer--base">
...
</div>
</div>
...
</div>
The css and markup haven't changed. But now I'm scrolling through the .home element, and not the .parallax element. The foreground and background layers are still in a 3d space, but it's only relative to the .perspective element.
Is there a way to somehow pass that perspective down to the homepages grandchildren, or great grandchildren? Or do I need to divide my entire page into foreground and background sections in order to achieve this effect?