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.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
feat: add parallax-depth-of-field static scaffold
matin754f62fbf475
diff --git a/animations/01-scroll-based/parallax-depth-of-field/index.html b/animations/01-scroll-based/parallax-depth-of-field/index.htmlnew file mode 100644index 00000000..8e1de92d--- /dev/null+++ b/animations/01-scroll-based/parallax-depth-of-field/index.html@@ -0,0 +1,177 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>Parallax Depth-of-Field</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; }++ header {+ position: fixed; top: 0; left: 0; right: 0; z-index: 100;+ padding: 16px 24px;+ background: linear-gradient(to bottom, rgba(6,10,16,.9), transparent);+ pointer-events: none;+ }+ header h1 { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }+ header p { font-size: 11px; color: var(--ui-muted); margin-top: 4px; }++ .scroll-stage { height: 500vh; position: relative; }+ .sticky-viewport { position: sticky; top: 0; height: 100vh; overflow: hidden; }++ .layer {+ position: absolute; top: 0; left: 0; width: 100%; height: 100%;+ will-change: transform, filter;+ }++ /* ── Sidebar ── */+ .sidebar {+ position: fixed; right: 0; top: 50%; transform: translateY(-50%);+ width: 112px; z-index: 200;+ background: var(--ui-bg); border: 1px solid var(--ui-border);+ border-right: none; border-radius: 8px 0 0 8px;+ padding: 16px 12px;+ display: flex; flex-direction: column; gap: 10px;+ }+ .s-label {+ font-size: 9px; text-transform: uppercase;+ letter-spacing: 1px; color: var(--ui-accent);+ }+ .slider-wrap {+ display: flex; flex-direction: column; align-items: center; gap: 4px;+ }+ .tick { font-size: 8px; color: var(--ui-muted); }+ input[type=range].focal-slider {+ writing-mode: vertical-lr; direction: rtl;+ -webkit-appearance: slider-vertical; appearance: slider-vertical;+ width: 28px; height: 96px; cursor: pointer;+ accent-color: var(--ui-accent);+ }+ .divider { height: 1px; background: var(--ui-border); }+ .readout { display: flex; flex-direction: column; gap: 3px; }+ .readout-row {+ display: flex; justify-content: space-between;+ font-size: 9px; color: var(--ui-muted);+ }+ .readout-row.focused { color: var(--ui-accent); }+ .readout-row .val { color: var(--ui-text); }++ @media (max-width: 600px) {+ .sidebar {+ right: auto; top: auto; bottom: 0; left: 0; width: 100%;+ transform: none; border-radius: 8px 8px 0 0;+ border: 1px solid var(--ui-border); border-bottom: none;+ flex-direction: row; align-items: center;+ padding: 10px 16px; gap: 10px;+ }+ .slider-wrap { flex-direction: row; }+ input[type=range].focal-slider {+ writing-mode: horizontal-tb; direction: ltr;+ -webkit-appearance: auto; appearance: auto;+ width: 110px; height: auto;+ }+ .tick { display: none; }+ .readout { flex-direction: row; gap: 8px; }+ }+ </style>+</head>+<body>++<header>+ <h1>Parallax Depth-of-Field</h1>+ <p>Five mountain layers translate at different speeds; a focal plane blurs each by its depth distance.</p>+</header>++<div class="scroll-stage">+ <div class="sticky-viewport">++ <!-- L5: Sky + stars (depth 0.0, static) -->+ <svg class="layer" id="l5" viewBox="0 0 1200 800"+ 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="1200" height="800" fill="url(#sky)"/>+ <circle cx="80" cy="55" r="1.2" fill="#fff" opacity=".5"/>+ <circle cx="210" cy="28" r="1" fill="#fff" opacity=".4"/>+ <circle cx="345" cy="88" r=".9" fill="#fff" opacity=".6"/>+ <circle cx="480" cy="18" r="1.3" fill="#fff" opacity=".3"/>+ <circle cx="600" cy="52" r="1" fill="#fff" opacity=".5"/>+ <circle cx="720" cy="33" r="1.1" fill="#fff" opacity=".4"/>+ <circle cx="865" cy="14" r=".8" fill="#fff" opacity=".6"/>+ <circle cx="950" cy="68" r="1.2" fill="#fff" opacity=".3"/>+ <circle cx="1055" cy="40" r="1" fill="#fff" opacity=".5"/>+ <circle cx="1150" cy="24" r=".9" fill="#fff" opacity=".4"/>+ <circle cx="155" cy="118" r=".8" fill="#fff" opacity=".3"/>+ <circle cx="395" cy="138" r="1" fill="#fff" opacity=".4"/>+ <circle cx="672" cy="108" r=".9" fill="#fff" opacity=".5"/>+ <circle cx="902" cy="128" r="1.1" fill="#fff" opacity=".3"/>+ </svg>++ <!-- L4: Distant peaks (depth 0.2) -->+ <svg class="layer" id="l4" viewBox="0 0 1200 800"+ preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">+ <polygon fill="#0d2b3e"+ points="0,500 80,340 180,400 300,280 420,360 540,260+ 660,320 780,290 900,330 1020,270 1140,310 1200,290 1200,800 0,800"/>+ </svg>++ <!-- L3: Mid mountains (depth 0.4) -->+ <svg class="layer" id="l3" viewBox="0 0 1200 800"+ preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">+ <polygon fill="#0f2236"+ points="0,530 100,390 220,440 360,320 480,400 600,310+ 720,370 840,345 960,382 1080,332 1200,360 1200,800 0,800"/>+ </svg>++ <!-- L2: Near hills (depth 0.7) -->+ <svg class="layer" id="l2" viewBox="0 0 1200 800"+ preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">+ <polygon fill="#0c1828"+ points="0,570 120,445 260,480 400,392 540,455 680,382+ 820,432 960,408 1100,442 1200,422 1200,800 0,800"/>+ </svg>++ <!-- L1: Foreground (depth 1.0) -->+ <svg class="layer" id="l1" viewBox="0 0 1200 800"+ preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">+ <polygon fill="#060810"+ points="0,612 160,502 320,542 480,472 640,522 800,482+ 960,522 1120,492 1200,508 1200,800 0,800"/>+ </svg>++ </div>+</div>++<aside class="sidebar">+ <div class="s-label">Focal Plane</div>+ <div class="slider-wrap">+ <span class="tick">far</span>+ <input type="range" class="focal-slider" id="focalSlider" min="0" max="100" value="0">+ <span class="tick">near</span>+ </div>+ <div class="divider"></div>+ <div class="s-label">Blur</div>+ <div class="readout" id="readout">+ <div class="readout-row" id="row-l5"><span>L5</span><span class="val">0px</span></div>+ <div class="readout-row" id="row-l4"><span>L4</span><span class="val">0px</span></div>+ <div class="readout-row" id="row-l3"><span>L3</span><span class="val">0px</span></div>+ <div class="readout-row" id="row-l2"><span>L2</span><span class="val">0px</span></div>+ <div class="readout-row" id="row-l1"><span>L1</span><span class="val">0px</span></div>+ </div>+</aside>++</body>+</html>