Building a Cinematic Parallax Scroll Effect with Pure HTML, CSS, and JavaScript
What is Parallax Scrolling?
- Far layers (background) → move slow
- Near layers (foreground) → move fast
The Layer Setup
hill1.png → mountains in the distance (slowest)
hill2.png → cliffs with a lone tree
hill3.png → tropical jungle mid-ground
hill4.png → rocky cliffs with vegetation
hill5.png → palm trees and foreground brush (fastest)
Each layer is positioned absolutely, covering the full viewport width, and stacked using z-index.
JavaScript — The Parallax Magic
Javascript
- hill1 * 0.1 → barely moves (far away)
- hill5 * 0.5 → moves the most (closest to viewer)
Performance Tip: Use transform Instead of top
Javascript
The Result
Project Repository
Bash