CSS Native Parallax

Scroll-driven parallax using view-timeline — no JavaScript, one utility class.

↓ scroll
Mountain

Just add a class

.parallax on the wrapper, one line of HTML. The browser handles the rest.

Bridge

Tune the depth

The --parallax-offset variable controls both travel distance and scale, so gaps are automatically covered.

Water

Off the main thread

Scroll-driven animations run on the compositor thread, so no jank — even on mobile.

Forest

Reduced motion? Handled.

prefers-reduced-motion disables both the animation and the scale in one media query block.

The recipe

The full implementation in a single CSS snippet — view-timeline does the heavy lifting.

.parallax {
  view-timeline-name: --parallax-tl;
  view-timeline-axis: block;
  overflow: hidden;

  & > * {
    scale: calc(1 + var(--parallax-offset, 20) * 2 / 100);
    animation: parallax auto linear both;
    animation-timeline: --parallax-tl;
    animation-range: cover;
    will-change: translate;
  }
}

@keyframes parallax {
  from { translate: 0 calc(var(--parallax-offset, 20) * -1%); }
  to   { translate: 0 calc(var(--parallax-offset, 20) * 1%); }
}
← back to favs.eu.org