Create parallax scrolling effects with CSS & JavaScript. Preview live, copy the code.
Scroll down to see the parallax effect
Background scrolls at a different speed
Creating depth through motion
Scroll down to see the parallax effect
The hero background moves at a different speed, creating a natural depth effect with pure CSS
Elements shift based on cursor position
Layer 1, slowest, furthest back
Layer 2, circles & diamonds
Layer 3, "DEPTH" & "LAYERS"
Layer 4, cityscape at bottom
Pure CSS parallax using the perspective trick. No JavaScript required in the generated code.
Pure CSS piling effect using position: sticky. Each section stacks on top of the previous one as you scroll. No JavaScript needed.
Scroll Parallax
Background images move at a different speed than content for a natural depth effect
Get production-ready parallax with scroll snapping, touch support, and optimized performance out of the box.
fullPage.js adds
The parallax effect is a visual technique where background elements move at a different speed than foreground content during scrolling. This creates an illusion of depth and immersion, making flat web pages feel three-dimensional.
The term comes from the Greek parallaxis (change in position). In web design, it translates to layered scrolling: backgrounds shift slowly while content scrolls at normal speed. When done well, it keeps users engaged and guides attention.
Below is a simple example using background-attachment: fixed, the most basic CSS parallax technique:
background-attachment: fixedThe simplest approach. The background image stays fixed relative to the viewport while content scrolls over it. Works in all desktop browsers but ignored on iOS Safari and many mobile browsers.
.parallax-section {
height: 100vh;
background-image: url('background.jpg');
background-attachment: fixed;
background-size: cover;
background-position: center;
}
perspective + translateZUses CSS 3D transforms to create real depth. Elements with negative translateZ values appear further away and move slower. More performant than background-attachment: fixed but requires careful setup.
.parallax-container {
height: 100vh;
overflow-x: hidden;
overflow-y: auto;
perspective: 1px;
}
.parallax-layer-back {
position: absolute;
inset: 0;
transform: translateZ(-1px) scale(2);
background: url('background.jpg') center/cover;
}
.parallax-layer-front {
position: relative;
transform: translateZ(0);
}
Use JavaScript to read scrollY and apply a transform to background elements. Offers full control over speed, direction, and easing, but requires requestAnimationFrame to avoid jank. Libraries like fullPage.js handle this optimally.
window.addEventListener('scroll', () => {
const scrolled = window.scrollY;
const bg = document.querySelector('.parallax-bg');
bg.style.transform = `translateY(${scrolled * 0.5}px)`;
}, { passive: true });
transform, not background-positionTransforms are GPU-accelerated and don't trigger layout recalculations. Always prefer translate3d for smooth 60fps animations.
prefers-reduced-motionSome users experience motion sickness. Wrap parallax animations in a @media (prefers-reduced-motion: no-preference) query.
Parallax sections use large background images. Compress with WebP/AVIF, use srcset for responsive sizes, and lazy-load below-the-fold sections.
background-attachment: fixed is ignored on iOS. DevTools emulation doesn't catch this. Test on real phones.
A slight offset (30-60%) is more elegant than extreme parallax. The effect should enhance content, not distract from it.
background-attachment: fixed on a container with a background image. For more depth control, use CSS 3D transforms with perspective on a parent and translateZ on child layers. Both are CSS-only but have limitations on mobile devices.background-attachment: fixed) does not work on most mobile browsers. iOS Safari and many Android browsers ignore it entirely. JavaScript-based solutions like fullPage.js provide consistent parallax across all devices including mobile.
How to use
data-parallax-layer="N" to any element
2. Lower N = slower, higher N = faster
3. Tune speeds in the speeds object
4. Elements without the attribute scroll normally
80+ scroll effects. One line of code. Used on 50,000+ websites.
Powering fullscreen design for Google, Sony, BBC, eBay & more