Skip to content

CSS 3D perspective scrolling

A pure-CSS parallax. perspective on the scroll container pushes each layer back with translateZ; layers farther from the vanishing point move slower. scale() compensates so they fill the viewport. No JS, no scroll events — just the browser's natural 3D projection during scroll.

Use this template View on GitHub

Pure CSS, no JavaScript

The depth effect is the browser's native 3D projection of translateZ-positioned layers inside a perspective scroll container. No scroll listeners, no animation frame loops, no jank. The compositor does all the work.

Four AVIF layers, ~600 KB total

Panoramic AVIF compresses 30–50% smaller than WebP. Four layers stacked at depths 8, 5, 2, 1 give a perceptible parallax range without bloating mobile load times. Lighthouse scores stay above 95.

MkDocs Material under the hood

Search, instant navigation, code-copy buttons, content tabs, admonitions, sticky tabs, dark or light themes. Everything Material gives you, plus the cinematic hero on top.

How it works

A scroll container with perspective: 2.5rem establishes a 3D context. Each layer is pushed back with translateZ and scaled to compensate. Layers further from the camera move slower as you scroll — the parallax is the browser's projection math, not a simulation.

The technique was originally built for Material for MkDocs. This repo is the standalone extraction: documented, scripted, and ready to drop into any project.

Read the deep dive →

Quickstart

Pick a host, click deploy, swap the four hero AVIFs for your own. The site is live in under five minutes — no account beyond your deploy platform, no JavaScript framework, no build pipeline beyond mkdocs build.

  1. Fork the repo via "Use this template"
  2. Click a one-click deploy button (Vercel, Netlify, Railway)
  3. Replace the four AVIFs in src/assets/hero/ with your art
  4. Edit hero copy in overrides/home.html — push, deploy auto-updates
Deploy now →