Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

feat: add parallax-scrolling static scaffold

matin746f912deec6
diff --git a/animations/01-scroll-based/parallax-scrolling/index.html b/animations/01-scroll-based/parallax-scrolling/index.html
new file mode 100644
index 00000000..dcf3776f
--- /dev/null
+++ b/animations/01-scroll-based/parallax-scrolling/index.html
@@ -0,0 +1,203 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Parallax Scrolling</title>
+ <style>
+ :root {
+ --bg:#060a10; --ui-bg:#0d1117; --ui-border:#21262d;
+ --ui-accent:#58a6ff; --ui-text:#c9d1d9; --ui-muted:#8b949e;
+ }
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
+ body{background:var(--bg);color:var(--ui-text);font-family:monospace;
+ padding:clamp(12px,3vw,24px)}
+
+ header{margin-bottom:20px}
+ header h1{font-size:clamp(11px,1.8vw,15px);letter-spacing:2px;text-transform:uppercase}
+ header p{font-size:clamp(10px,1.2vw,12px);color:var(--ui-muted);margin-top:4px}
+
+ .layout{display:flex;gap:clamp(12px,2vw,24px);align-items:flex-start}
+
+ .stage{
+ flex:1;min-width:0;height:600px;
+ overflow-y:scroll;scrollbar-width:none;
+ border:1px solid var(--ui-border);border-radius:8px;
+ }
+ .stage::-webkit-scrollbar{display:none}
+ .scene{height:1800px}
+ .layers{position:sticky;top:0;height:600px;overflow:hidden}
+ .layer{
+ position:absolute;top:0;left:0;width:100%;height:600px;
+ will-change:transform;
+ }
+ .layer svg{width:100%;height:100%}
+
+ aside{
+ width:clamp(180px,20vw,220px);flex-shrink:0;
+ background:var(--ui-bg);border:1px solid var(--ui-border);
+ border-radius:8px;padding:16px;
+ display:flex;flex-direction:column;gap:10px;
+ }
+ .note{
+ font-size:10px;color:var(--ui-muted);line-height:1.6;
+ border-left:2px solid var(--ui-accent);padding-left:8px;
+ }
+ .lbl{font-size:9px;text-transform:uppercase;letter-spacing:1px;color:var(--ui-accent)}
+ .row{display:flex;justify-content:space-between;font-size:10px}
+ .row .v{color:var(--ui-text)}
+ .tbl{display:flex;flex-direction:column;gap:2px}
+ .tbl .row{font-size:9px;color:var(--ui-muted)}
+ .sliders{display:flex;flex-direction:column;gap:5px}
+ .sr{display:flex;align-items:center;gap:5px;font-size:9px}
+ .sr label{width:42px;color:var(--ui-muted);flex-shrink:0}
+ .sr input[type=range]{flex:1;accent-color:var(--ui-accent);min-height:20px}
+ .sr .sv{width:32px;text-align:right;color:var(--ui-text)}
+ .div{height:1px;background:var(--ui-border)}
+ .tog{display:flex;align-items:center;gap:8px;font-size:10px;cursor:pointer}
+ .tog input{accent-color:var(--ui-accent);width:16px;height:16px;flex-shrink:0}
+ button{
+ background:transparent;border:1px solid var(--ui-border);
+ color:var(--ui-text);font-family:monospace;font-size:10px;
+ padding:8px;border-radius:4px;cursor:pointer;width:100%;
+ }
+ button:hover{border-color:var(--ui-accent);color:var(--ui-accent)}
+
+ @media(max-width:600px){
+ .layout{flex-direction:column}
+ aside{width:100%}
+ .stage{height:400px}
+ .layers{height:400px}
+ .layer{height:400px}
+ }
+ @media(min-width:601px) and (max-width:1024px){
+ .sr input[type=range]{min-height:28px}
+ }
+ @media(prefers-reduced-motion:reduce){.layer{will-change:auto}}
+ </style>
+</head>
+<body>
+
+<header>
+ <h1>Parallax Scrolling</h1>
+ <p>Elements move at different speeds — background slower, foreground faster — creating a 3D depth illusion.</p>
+</header>
+
+<div class="layout">
+
+ <div class="stage" id="stage">
+ <div class="scene">
+ <div class="layers">
+
+ <!-- L1: Sky + stars (speed 10%) -->
+ <div class="layer" id="l1">
+ <svg viewBox="0 0 800 600" preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">
+ <defs>
+ <linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0%" stop-color="#0a1628"/>
+ <stop offset="100%" stop-color="#060a10"/>
+ </linearGradient>
+ </defs>
+ <rect width="800" height="600" fill="url(#sky)"/>
+ <circle cx="80" cy="55" r="1.2" fill="#fff" opacity=".5"/>
+ <circle cx="200" cy="28" r="1" fill="#fff" opacity=".4"/>
+ <circle cx="330" cy="78" r=".9" fill="#fff" opacity=".6"/>
+ <circle cx="470" cy="18" r="1.3" fill="#fff" opacity=".3"/>
+ <circle cx="580" cy="52" r="1" fill="#fff" opacity=".5"/>
+ <circle cx="680" cy="33" r="1.1" fill="#fff" opacity=".4"/>
+ <circle cx="755" cy="14" r=".8" fill="#fff" opacity=".6"/>
+ <circle cx="140" cy="108" r=".9" fill="#fff" opacity=".3"/>
+ <circle cx="420" cy="96" r="1" fill="#fff" opacity=".4"/>
+ <circle cx="640" cy="116" r=".8" fill="#fff" opacity=".3"/>
+ </svg>
+ </div>
+
+ <!-- L2: Distant ridgeline (speed 30%) -->
+ <div class="layer" id="l2">
+ <svg viewBox="0 0 800 600" preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">
+ <polygon fill="#0d2b3e"
+ points="0,380 60,258 130,298 220,208 310,268 400,193
+ 490,243 580,213 660,253 740,223 800,236 800,600 0,600"/>
+ </svg>
+ </div>
+
+ <!-- L3: Pine treeline (speed 60%) -->
+ <div class="layer" id="l3">
+ <svg viewBox="0 0 800 600" preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">
+ <polygon fill="#0a1f2e"
+ points="0,442 35,362 65,380 95,320 135,344 175,297 215,324
+ 265,287 305,310 360,274 400,297 450,262 490,284
+ 540,270 580,294 635,280 675,304 720,287 760,310
+ 800,294 800,600 0,600"/>
+ </svg>
+ </div>
+
+ <!-- L4: Foreground grass (speed 100%) -->
+ <div class="layer" id="l4">
+ <svg viewBox="0 0 800 600" preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">
+ <polygon fill="#050e08"
+ points="0,497 80,452 160,472 240,450 320,467 400,454
+ 480,470 560,457 640,472 720,458 800,464 800,600 0,600"/>
+ <ellipse cx="100" cy="507" rx="60" ry="15" fill="#040c07"/>
+ <ellipse cx="280" cy="514" rx="70" ry="18" fill="#030b06"/>
+ <ellipse cx="500" cy="508" rx="65" ry="16" fill="#040c07"/>
+ <ellipse cx="700" cy="502" rx="55" ry="14" fill="#040c07"/>
+ </svg>
+ </div>
+
+ </div>
+ </div>
+ </div>
+
+ <aside>
+ <p class="note">Real cameras render depth geometrically — layers slow down roughly as 1/distance. Try ratios like 100% / 60% / 30% / 10% for the most believable depth.</p>
+
+ <div>
+ <div class="lbl">Scroll Progress</div>
+ <div class="row"><span>Progress</span><span class="v" id="progress">0%</span></div>
+ </div>
+
+ <div>
+ <div class="lbl">Layer Offsets</div>
+ <div class="tbl">
+ <div class="row"><span>Sky</span><span class="v" id="off1">0px</span></div>
+ <div class="row"><span>Ridgeline</span><span class="v" id="off2">0px</span></div>
+ <div class="row"><span>Treeline</span><span class="v" id="off3">0px</span></div>
+ <div class="row"><span>Grass</span><span class="v" id="off4">0px</span></div>
+ </div>
+ </div>
+
+ <div class="div"></div>
+
+ <div>
+ <div class="lbl">Speed Multipliers</div>
+ <div class="sliders">
+ <div class="sr"><label>Sky</label>
+ <input type="range" id="s1" min="0" max="150" value="10">
+ <span class="sv" id="sv1">10%</span></div>
+ <div class="sr"><label>Ridge</label>
+ <input type="range" id="s2" min="0" max="150" value="30">
+ <span class="sv" id="sv2">30%</span></div>
+ <div class="sr"><label>Trees</label>
+ <input type="range" id="s3" min="0" max="150" value="60">
+ <span class="sv" id="sv3">60%</span></div>
+ <div class="sr"><label>Grass</label>
+ <input type="range" id="s4" min="0" max="150" value="100">
+ <span class="sv" id="sv4">100%</span></div>
+ </div>
+ </div>
+
+ <div class="div"></div>
+
+ <label class="tog">
+ <input type="checkbox" id="tog">
+ <span>Disable parallax (all 100%)</span>
+ </label>
+
+ <button id="resetBtn">Reset to defaults</button>
+ </aside>
+
+</div>
+
+</body>
+</html>