You multiply scroll distance by a per-layer factor (say background ×0.2, midground ×0.5, foreground ×1) to get how far each layer moves. Closer to 1 tracks the screen; closer to 0 barely moves, reading as distant.
CSS alone only gets you background-attachment: fixed, so in practice you update each layer's transform from a scroll listener (or IntersectionObserver). With many layers this can jank the scroll frame, so stick to transform only — never layout properties like top or margin.
Since a card preview can't be scrolled, this demo moves the layers on its own, like a camera panning through the scene, instead of waiting for scroll input.
When to use
Save it for a single hero section. Overusing it across a whole page can trigger motion sickness.