The short version
- A parallax effect creates depth by moving layers at different speeds, with nearer layers moving faster than distant ones.
- On websites, parallax scrolling can now be built in CSS with scroll-driven animations, without JavaScript, in browsers that support them.
- The older
background-attachment: fixedtechnique is ignored by iOS Safari, so it should not be relied on for mobile. - Large or fast parallax movement can cause discomfort for people with vestibular disorders, so it should be turned off when a visitor prefers reduced motion.
- Subtle parallax, with layers moving only a little, adds depth without distracting from the content.
On this page
A parallax effect makes a flat design feel deep by moving its layers at different speeds: the background drifts slowly, the middle a little faster, and the foreground fastest, just as distant hills seem to crawl past a train window while the fence posts race by. On websites it usually happens as you scroll. In motion design it happens over time, in a loop or a video. Either way, the best parallax is small, slow and switched off for anyone who has asked their device for less motion.
How parallax creates depth
Your brain judges distance partly from relative movement. When two layers move at the same speed they read as one flat surface. When one moves more slowly, it reads as further away. Three layers are usually enough to create convincing depth.
Speed relative to scroll
What goes on it
What goes on it
Speed relative to scroll
What goes on it
Parallax effect in CSS with scroll-driven animations
Modern CSS can tie an animation to scroll position instead of time, using animation-timeline. The browser runs it off the main thread, so it stays smooth, and no JavaScript is needed. Support is still growing: it works in Chromium browsers and recent Safari, so check browser support on MDN and treat the effect as an enhancement. Without support, the page simply doesn't move, which is fine.
.hero {
position: relative;
overflow: clip;
isolation: isolate; /* keeps the layer inside the hero */
min-height: 80vh;
view-timeline: --hero block;
}
.hero__bg {
position: absolute;
inset: -15% 0; /* extra room so edges never show */
background:
radial-gradient(circle at 75% 20%, #7c3aed 0%, transparent 45%),
linear-gradient(170deg, #0f0b1e 0%, #1e1b4b 100%);
z-index: -1;
}
@media (prefers-reduced-motion: no-preference) {
@supports (animation-timeline: view()) {
.hero__bg {
animation: hero-depth linear both;
animation-timeline: --hero;
}
}
}
@keyframes hero-depth {
from { transform: translateY(-10%); }
to { transform: translateY(10%); }
}The size of the movement lives in the keyframes: 10% each way is gentle. Push it beyond 20% and the effect starts to feel like a ride. Moving transform rather than top or background-position keeps it cheap for the browser to draw. CSS gradient performance explains why large animated gradients should move, not repaint.
Other ways to build parallax scrolling
How it works
animation-timeline: view() or scroll() ties keyframes to scrollWatch out for
background-attachment: fixedHow it works
Watch out for
How it works
translateZ scroll more slowlyWatch out for
How it works
Watch out for
requestAnimationFrameParallax and reduced motion
For people with vestibular disorders, large movement triggered by scrolling can cause dizziness and nausea. WCAG's guidance on animation from interactions asks that motion like this can be turned off. The simplest way to respect that is to wrap parallax in prefers-reduced-motion: no-preference, as in the code above, so it only runs for visitors who haven't asked for less motion. Prefers reduced motion covers the media query and how to test it.
Avoid
- Whole sections sliding at different speeds
- Text or buttons on moving layers
- Movement that ignores reduced motion settings
- Scroll hijacking that changes scroll speed
- Parallax on every section of the page
Do
- One background layer moving a little
- Content on the normal scroll
- Motion only under
no-preference - Native scrolling, untouched
- Parallax in one place: usually the hero
Parallax in motion design and video
Parallax isn't only for scrolling. In a moving post, a loop or a title sequence, the same rule creates depth over time: a background that drifts slowly, light or particles that move slightly faster, and words that hold still in front. That last part matters. Still words on a gently moving field read as calm and confident, while words that drift too look unsettled.
A website hero with depth: the background field moves slowly behind still words, so the eye reads the headline first.
Particles are a natural middle layer: particle effects shows how small, faint specks moving slightly faster than the background add a second plane of depth. Keep every layer's motion slow and eased; motion design principles explains why.
Designing a parallax hero, step by step
- 1
Design it still first
The hero must look finished with no movement at all, because that's what reduced motion visitors and unsupported browsers will see.
- 2
Separate the layers
Put the background colour field on its own layer, any shapes or photos on a second, and the headline and button on the page itself.
- 3
Move only the back layer
Start with the background alone moving 10% each way. Add a middle layer only if the depth needs it.
- 4
Test on a phone
Check it scrolls smoothly on a mid range phone, and that nothing jumps on iOS Safari.
- 5
Turn on reduced motion and check again
In your system's accessibility settings, ask for reduced motion and confirm the page is calm and complete.
For the background layer itself, a living gradient does more than a flat one. A Gradiently Mark exported as a seamless WebM or MP4 loop with Pro, set behind your hero, gives the page a back layer that is already moving gently and belongs to you alone once claimed. Pair it with hero section design and website hero backgrounds for sizing.
Questions people ask
What is a parallax effect?
A way of creating depth by moving layers at different speeds, so nearer layers move faster than distant ones, as they do in real life.
Can I make a parallax effect with only CSS?
Yes. CSS scroll-driven animations tie keyframes to scroll position without JavaScript, in browsers that support animation-timeline. Older pure CSS methods use background-attachment: fixed or 3D perspective.
Why doesn't background-attachment: fixed work on iPhone?
iOS Safari ignores fixed background attachment, so the background scrolls normally. Use scroll-driven animations or a transform based technique instead.
Is parallax scrolling bad for accessibility?
Large scroll-triggered movement can make people with vestibular disorders feel unwell. Keep it subtle and turn it off when a visitor prefers reduced motion.
Is parallax bad for performance?
Not if you animate transform and let the browser drive it with scroll-driven animations. Scripts that move elements on every scroll event are what cause stutter.
Written by Gradiently
The team behind Gradiently, a design tool built around Marks: living gradients that make everything you design look like yours.
See our profile