# Parallax Scrolling

> An image that moves slower than the page inside its frame as it scrolls past, using a view() scroll timeline.

- Category: [CSS Effects](https://copy-css.com/category/effects)
- Tags: parallax, scroll-driven, view timeline, image, depth, hero
- Live preview: https://copy-css.com/snippets/parallax-scrolling
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<div class="parallax-frame">
  <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 40'%3E%3Crect width='60' height='40' fill='%23bae6fd'/%3E%3Ccircle cx='14' cy='11' r='6' fill='%23fde047'/%3E%3Cpath d='M0 40V30l15-6 15 5 15-7 15 6v12z' fill='%2334d399'/%3E%3Cpath d='M36 31l5-15 5 15zM45 32l4-11 4 11zM8 36l4-12 4 12z' fill='%23047857'/%3E%3C/svg%3E" alt="Green hills and pine trees on a sunny day" width="280" height="220">
</div>
```

## CSS

```css
.parallax-frame {
  width: 100%;
  max-width: 280px;
  height: 160px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 16px;
}

.parallax-frame img {
  display: block;
  width: 100%;
  height: 140%;
  object-fit: cover;
}

@supports (animation-timeline: view()) {
  .parallax-frame img {
    animation: parallax-frame-shift linear both;
    animation-timeline: view();
  }
}

@keyframes parallax-frame-shift {
  from {
    transform: translateY(-28%);
  }

  to {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .parallax-frame img {
    height: 100%;
    animation: none;
  }
}
```

## Notes

- This CSS Parallax Scrolling is 39 lines of pure CSS (0.6 KB) with no JavaScript and no dependencies. It uses scroll-driven animations, keyframe animations, transforms and reduced-motion support.
- scroll-driven animations: Chrome and Edge 115+ and Safari 26+. Firefox support is very recent; browsers without it skip the animation and show the content as is.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
