- background-attachment: fixed anchors the image to the viewport, not to the element.
- Many mobile browsers render fixed as scroll, which quietly removes the parallax effect.
- A transform-based layer works on more devices than background-attachment alone.
- prefers-reduced-motion lets you turn off parallax movement for users who asked for less of it.
What background-attachment actually does
background-attachment controls what an image stays anchored to while the page scrolls. It takes three values, and the differences between them explain most parallax behavior.
| Value | Anchored to | Result while scrolling |
|---|---|---|
scroll | The element's own box | Moves with the page as the element moves, the default |
fixed | The viewport | Stays in place while the rest of the page scrolls past it |
local | The element's scrollable content | Scrolls together with the element's own internal scroll |
The property reference for the rest of the background shorthand, including size and position, is in the CSS background-image guide.
Why fixed creates a parallax illusion
Because a fixed background stays pinned to the viewport instead of moving with the page content, it appears to drift at a different speed than the text and images scrolling over it. That mismatch in apparent speed is the entire parallax effect, achieved with one line of CSS and no JavaScript.
A wide, atmospheric scene such as the synthwave grid background is the kind of image this technique suits well: a single full-bleed layer with no foreground element of its own that needs to move independently.
The effect reads most convincingly over a tall section, since there needs to be enough scroll distance for the speed difference to register. A short banner barely gives the eye time to notice the image lagging behind, while a section spanning most of the viewport height makes the separation between the fixed layer and the scrolling content obvious.

A simpler fixed-background recipe without the pitfalls
Before reaching for a script, it is worth seeing the plain CSS version in full, since it still has its place for a single, calm section rather than a whole page.
.parallax-section {
background-image: url("synthwave-grid.jpg");
background-attachment: fixed;
background-position: center;
background-size: cover;
min-height: 60vh;
}This works cleanly when the section is tall enough to show the parallax motion before it scrolls away, and when the page does not depend on it rendering identically everywhere. It breaks down the moment the design assumes the effect will always appear, or stacks several fixed backgrounds on the same page, since each one adds its own repaint cost during scroll.
Where fixed breaks down on mobile
Mobile browsers, including Safari on iOS, have a long history of treating background-attachment: fixed unreliably, commonly falling back to behaving like scroll instead. The usual reason given is how these browsers composite layers during scrolling to keep the page smooth, and fixed backgrounds complicate that.
The practical result is that a parallax effect built only on fixed can simply disappear on a phone, with the image scrolling normally instead. Since you cannot rely on fixed rendering consistently everywhere, the layout still needs to look acceptable in its fallback, scrolled state.
Treat the scrolled fallback as the real design, not an edge case. Check text contrast, spacing and crop with the background in its normal, scrolling position, since that is what a large share of visitors will actually see. If the design only works with the parallax motion present, it is not ready to ship, because a meaningful slice of mobile traffic will never see that motion at all.

A steadier approach: transform-based parallax
A more consistent technique separates the image into its own layer and moves it with transform instead of relying on background-attachment. A common structure places an absolutely positioned image inside a taller, overflow-hidden wrapper, then shifts it as the user scrolls.
.parallax {
position: relative;
overflow: hidden;
}
.parallax img {
position: absolute;
inset: 0;
width: 100%;
height: 120%;
object-fit: cover;
transform: translateY(var(--parallax-offset, 0));
will-change: transform;
}A script updates --parallax-offset based on scroll position, usually inside requestAnimationFrame to avoid doing the work on every scroll event. A quiet, layered scene such as the misty forest background reads well with this kind of subtle shift.
Keep the oversized image taller than its wrapper, as the 120% height above does, so the translation has room to move without ever exposing an empty edge at the top or bottom of the section. A small offset, often no more than a quarter of the section's own height, is usually enough to read as parallax without the image visibly outrunning the content around it.
CSS also has a newer, native path for the same idea through scroll-driven animations, which link an animation's progress directly to scroll position using animation-timeline: scroll() instead of a scroll event listener. Support is still filling in across browsers at the time of writing, so a script-driven fallback remains the safer default for production work.
prefers-reduced-motion for parallax
prefers-reduced-motion is a media feature with two values, no-preference and reduce. It matches when a user has asked their system to minimize non-essential motion, and parallax scrolling is exactly the kind of effect that feature exists for.
@media (prefers-reduced-motion: reduce) {
.parallax img {
transform: none;
}
}Wrapping the transform update itself in a matching JavaScript check, not only the CSS fallback, avoids running the scroll listener at all for users who opted out, which also saves a small amount of work on every scroll frame.
Performance notes for fixed and parallax
background-attachment: fixed can force extra repaint work during scrolling even on desktop browsers that support it correctly, since the browser has to repaint the fixed layer relative to the viewport on every frame rather than simply compositing it. The same measurement approach used for Largest Contentful Paint in fast background images applies here too, a fixed hero is still a large image and still a strong LCP candidate, parallax or not.
A transform-based layer tends to be cheaper, because transform and opacity changes can run on the compositor thread without triggering layout or repaint, the same property pair used for most smooth CSS animations. That is also why the recipe above moves the image into its own element rather than animating a background position directly.
Animating background-position itself is worth avoiding for the same reason regardless of which technique you pick: every step requires the browser to repaint the affected area, since position and size changes on a background are not handled by the compositor the way transform and opacity are. A scroll-linked effect built on repeated background-position changes tends to feel noticeably less smooth than one built on a transformed layer, especially on lower powered phones.
A checklist before shipping a parallax background
- Decide what the layout looks like if fixed falls back to scroll, since it will on some devices.
- Prefer a transform-based layer over background-attachment: fixed for anything that must work consistently.
- Respect prefers-reduced-motion in both the CSS and the script driving the effect.
- Keep the moving layer to transform and opacity changes to avoid layout and paint costs.
- Test on a real phone, not only a desktop browser's device emulation mode.


