Parallax hero

Background and foreground layers of a hero move at different speeds while the page scrolls.

ScrollScroll progress CSS scroll-timelineGSAP scroll-progress-based Targets: Web · App Chrome/Edge 115+, Safari 26+, Firefox behind flag; JS fallback included
Scroll inside the frame ↕
Target
Implement the "Parallax hero" effect in vanilla HTML/CSS/JS.

Context: Background and foreground layers of a hero move at different speeds while the page scrolls.
Trigger: the page scrolls; progress is bound to scroll position, not time.
Timeline: scroll-progress-based (map scroll position to animation progress; no fixed duration).

Motion tokens (normal):
- translateY (background): 0 → -20% of hero height
- translateY (foreground): 0 → -60% of hero height
- opacity (foreground): 1 → 0
- scroll range: 0% (hero top at scroller top) → 100% (hero fully scrolled out)
- easing: linear

Motion tokens (prefers-reduced-motion):
- opacity (foreground): 1 → 0
- scroll range: 0% → 100%
- easing: linear
- note: no parallax displacement; layers scroll together

Technique: prefer CSS `animation-timeline: scroll()/view()` inside `@supports (animation-timeline: scroll())`, with a JS fallback; GSAP (ScrollTrigger where relevant) is acceptable as an alternative.

Acceptance:
- animate only transform and opacity unless the spec lists other properties
- no layout shift; content is visible without the animation
- when prefers-reduced-motion is set, use the reduced tokens only
- layers move only with transform; no background-position animation
- hero text remains readable at scroll 0

Generated from the spec. Prompts differ by target name only; the tokens are the source of truth.