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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex">
<title>Our version: The headset that comes apart as you scroll</title>
<style>
@font-face{font-family:'Schibsted Grotesk';src:url('../../assets/fonts/schibsted-latin-ext.woff2') format('woff2');font-weight:400 900;font-display:swap;unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:'Schibsted Grotesk';src:url('../../assets/fonts/schibsted-latin.woff2') format('woff2');font-weight:400 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
:root{--H:100vh;--g1:0 0 2em rgba(110,168,255,.25);--g2:0 0 1em rgba(63,214,196,.45);color-scheme:dark}
@supports(height:100svh){:root{--H:100svh}}
html.lite{--g1:0 0 #0000;--g2:0 0 #0000}
*{box-sizing:border-box;margin:0}
html{background:#0b0b0f;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#3c3c4a #0b0b0f}
body{color:#f4f4f2;font:400 15px/1.5 'Schibsted Grotesk',system-ui,-apple-system,'Segoe UI',sans-serif;-webkit-font-smoothing:antialiased}
.track{--w:min(62vw,calc(var(--H) * .62),480px);position:relative;height:calc(var(--H) * 3.3);overflow:clip}
.stage{position:sticky;top:0;height:var(--H);overflow:hidden;background:radial-gradient(circle 80vmin at 50% 44%,rgba(110,168,255,.2),rgba(185,140,255,.08) 55%,transparent),#0b0b0f}
.scene{--sh:var(--H);position:absolute;inset:0;font-size:calc(var(--w) / 10)}
.pw{position:absolute;left:50%;top:50%;width:0;height:0;perspective:32em}
.obj{position:absolute;left:-5em;top:-2.275em;width:10em;height:4.55em;transform-style:preserve-3d}
.pp{transform:translateY(calc(var(--sh) * .5))}
.parts{transform:rotateY(-16deg) rotateX(66deg)}
.pb{transform:translateY(calc(var(--sh) * 1.059))}
.body{transform:rotateY(-10deg) rotateX(100deg)}
.l{position:absolute;inset:0}
.glass,.frame,.pl1,.back{border-radius:34% / 50%}
.glass{--s2:linear-gradient(114deg,transparent 36%,rgba(255,255,255,.55) 37.3%,transparent 38.7%);transform:translateZ(1.19em);background:var(--s2),linear-gradient(114deg,transparent 21%,rgba(255,255,255,.55) 26.3%,transparent 31.7%),linear-gradient(180deg,rgba(255,255,255,.22),transparent 48%),linear-gradient(135deg,rgba(110,168,255,.66),rgba(63,214,196,.5));box-shadow:inset 0 0 0 .07em rgba(255,255,255,.6),inset 0 -.6em 1.2em rgba(63,214,196,.3),var(--g1)}
.frame,.band{border:solid transparent;-webkit-mask:linear-gradient(#000 0 0) padding-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) padding-box,linear-gradient(#000 0 0);mask-composite:exclude}
.frame{inset:-.28em;border-width:.5em;transform:translateZ(.385em);background:linear-gradient(135deg,#e2d2ff,#b98cff 45%,#7d57dd) border-box}
.pl1{inset:.2em;transform:translateZ(-.385em);background:linear-gradient(135deg,rgba(185,140,255,.5),rgba(110,168,255,.26));box-shadow:inset 0 0 0 .07em rgba(255,255,255,.5)}
.pl2{inset:-.1em .5em;border-radius:99em;transform:translateZ(-1.19em);box-shadow:inset 0 0 0 .32em rgba(110,168,255,.9),inset 0 0 0 .38em rgba(255,255,255,.4)}
.back{inset:-.28em;transform:translateZ(.32em);background:radial-gradient(120% 140% at 50% 30%,#242d5a,#10142a 70%);box-shadow:inset 0 0 0 .4em #5b43b4,inset 0 0 0 .47em rgba(255,255,255,.38)}
.lens{transform:translateZ(-.24em);transform-style:preserve-3d}
.lens span{position:absolute;inset:0;backface-visibility:hidden}
.lens .b{transform:rotateY(180deg)}
.lens i{position:absolute;top:50%;width:2.4em;aspect-ratio:1;margin:-1.2em 0 0 -1.2em;border-radius:50%}
.lens i:first-child{left:28%}
.lens i:last-child{left:72%}
.a i{background:radial-gradient(circle at 36% 30%,#4b5c93,#10142a 62%);box-shadow:inset 0 0 0 .08em rgba(63,214,196,.6)}
.b i{background:#fff;box-shadow:inset 0 0 0 .14em #3fd6c4,inset 0 0 0 .3em #0e1226,inset 0 0 0 .44em #6ea8ff,inset 0 0 0 .6em #0e1226,inset 0 0 0 .74em #b98cff,inset 0 0 0 .96em #0e1226,var(--g2)}
.band{inset:-.28em -1.15em;border-width:.4em;border-radius:99em;transform:translateZ(-.8em);background:linear-gradient(90deg,#ff6f8b,#ff9d5c 50%,#ff6f8b) border-box}
.top,.end{position:absolute;left:0;right:0;margin:0 auto;width:min(26em,calc(100% - 32px));text-align:center;z-index:1}
.top{top:0;padding-top:16px}
.end{bottom:0;padding-bottom:14px}
h1,h2{font-size:clamp(18px,1.2vw + 12px,30px);line-height:1.15;font-weight:700;letter-spacing:-.01em;text-wrap:balance}
.top p,.end p,.still p{margin-top:.4em;font-size:clamp(15px,.45vw + 12px,17px);color:#c3c4d0;text-wrap:pretty}
.stills{display:none;max-width:920px;margin:auto;padding:48px clamp(16px,4vw,40px) clamp(16px,4vw,40px)}
.still{display:grid;gap:8px 28px;align-items:center;margin:28px 0}
.pic .scene{position:relative;inset:auto;width:100%;--w:min(60vw,300px,calc(var(--H) * .62));--sh:calc(var(--w) * 1.1);height:var(--sh);overflow:hidden;border-radius:14px;border:1px solid rgba(255,255,255,.08);background:radial-gradient(circle at 50% 42%,rgba(110,168,255,.18),transparent 70%),#0b0b0f}
@media(min-width:640px){.still{grid-template-columns:1fr 1fr}}
.lite .glass{--s2:linear-gradient(#0000,#0000)}
@media(prefers-reduced-motion:reduce){.track{display:none}.stills{display:block}}
</style>
<script>
{
const q = '(max-width:600px),(max-height:500px)';
let lite;
try { lite = window.parent.matchMedia(q).matches; } catch (e) { lite = screen.width <= 600 || screen.height <= 500; }
document.documentElement.classList.toggle('lite', lite);
}
</script>
</head>
<body>
<main class="track">
<div class="stage">
<div class="scene" role="img" aria-label="A wide, rounded visor drawn in layers. First its parts, a blue and teal glass, a violet frame and two thin plates, rise apart as a stack and are carried off the top. Then the body, a dark back with two round lenses ringed in light and a coral band, swings up behind them and turns to face you.">
<div class="pw pb"><div class="obj body">
<div class="l back"></div>
<div class="l lens"><span class="a"><i></i><i></i></span><span class="b"><i></i><i></i></span></div>
<div class="l band"></div>
</div></div>
<div class="pw pp"><div class="obj parts">
<div class="l glass"></div>
<div class="l frame"></div>
<div class="l pl1"></div>
<div class="l pl2"></div>
</div></div>
</div>
</div>
<header class="top"><h1>A visor, taken apart</h1><p>Scroll, and its parts lift away one above the other and rise out of sight.</p></header>
<footer class="end"><h2>Two lenses face you</h2><p>With the front parts gone, the body turns round and shows its lenses, each ringed in light.</p></footer>
</main>
<section class="stills">
<h1>The visor in three pictures</h1>
<figure class="still"><div class="pic" data-alt="A stack of the visor's parts, a glass, a frame and two thin plates, lifted apart one above the other"></div><figcaption><h2>A stack of parts</h2><p>The glass, the frame and two thin plates lift apart, one above the other.</p></figcaption></figure>
<figure class="still"><div class="pic" data-alt="The body of the visor, seen at a slant, swinging up and starting to turn toward you"></div><figcaption><h2>The body swings up</h2><p>Behind them, the body rises and starts to turn toward you.</p></figcaption></figure>
<figure class="still"><div class="pic" data-alt="The body of the visor facing you, its two round lenses ringed in light in the middle"></div><figcaption><h2>Two lenses face you</h2><p>With the front parts gone, the body turns round and shows its lenses, each ringed in light.</p></figcaption></figure>
</section>
<script>
const $ = s => document.querySelector(s), $$ = s => [...document.querySelectorAll(s)];
const clamp = (v, a, b) => Math.min(Math.max(v, a), b);
const ss = (a, b, x) => { x = clamp((x - a) / (b - a), 0, 1); return x * x * (3 - 2 * x); };
const reduce = matchMedia('(prefers-reduced-motion: reduce)'), FRAME = 1000 / 60, SF = 1.7;
const ZP = [3.4, 1.1, -1.1, -3.4], XP = [7, 5, 3, 1.5], ZB = [.4, -.3, -1];
const parts = r => ({ pl: [...r.querySelectorAll('.parts .l')], bl: [...r.querySelectorAll('.body .l')], pp: r.querySelector('.pp'), bo: r.querySelector('.body'), pb: r.querySelector('.pb') });
function pose(p, s) {
const spread = .35 + .65 * ss(0, 1.2, s), carry = ss(.7, 1.7, s), t = ss(.8, SF, s), sb = .3 + .5 * (1 - t);
p.pl.forEach((el, i) => { el.style.transform = `translateZ(${(ZP[i] * spread + XP[i] * carry).toFixed(3)}em)`; });
p.pp.style.transform = `translateY(calc(var(--sh) * ${(.5 - .85 * s).toFixed(4)}))`;
p.bl.forEach((el, i) => { el.style.transform = `translateZ(${(ZB[i] * sb).toFixed(3)}em)`; });
p.pb.style.transform = `translateY(calc(var(--sh) * ${(-.08 + .67 * Math.max(0, SF - s)).toFixed(4)}))`;
p.bo.style.transform = `rotateY(${(-10 + 24 * t).toFixed(2)}deg) rotateX(${(100 + 88 * t).toFixed(2)}deg)`;
}
const main = parts($('.scene')), stage = $('.stage');
let H = 1, END = 0, SMAX = 2.3, cur = 0, tgt = 0, raf = 0, lastT = null, playing = false, pos = 0, acted = false;
function measure() {
H = stage.clientHeight || 1; END = document.documentElement.scrollHeight - innerHeight; SMAX = END / H;
}
function snap() { cur = tgt = clamp(scrollY / H, 0, SMAX); if (!reduce.matches) pose(main, cur); }
function tick(ts) {
raf = 0;
const first = lastT === null, dt = first ? 0 : Math.min(ts - lastT, 50);
lastT = ts;
if (playing) {
pos = Math.min(END, pos + dt * END / 6000);
scrollTo({ top: pos, behavior: 'instant' });
if (pos >= END) playing = false;
}
const y = scrollY;
if (playing && Math.abs(y - pos) > 3) playing = false;
tgt = clamp(y / H, 0, SMAX);
if (Math.abs(tgt - cur) > 1.5) cur = tgt;
cur += (tgt - cur) * (1 - Math.pow(1 - .14, (first ? FRAME : dt) / FRAME));
if (Math.abs(tgt - cur) < .0004) cur = tgt;
if (!reduce.matches) pose(main, cur);
if (playing || cur !== tgt) raf = requestAnimationFrame(tick); else lastT = null;
}
const wake = () => { if (!raf) raf = requestAnimationFrame(tick); };
function play() {
measure();
if (END <= 0) return;
if (scrollY >= END - 2) scrollTo({ top: 0, behavior: 'instant' });
pos = scrollY; playing = true; lastT = null; wake();
}
function toTop() { playing = false; scrollTo({ top: 0, behavior: 'instant' }); snap(); }
addEventListener('message', e => {
if (e.source !== parent || !e.data) return;
if (e.data.fx === 'play') { acted = true; play(); } else if (e.data.fx === 'top') { acted = true; toTop(); }
});
['wheel', 'touchstart', 'pointerdown', 'keydown'].forEach(t => addEventListener(t, e => { if (e.isTrusted) { acted = true; playing = false; } }, { passive: true, capture: true }));
addEventListener('scroll', () => { if (!reduce.matches) wake(); }, { passive: true });
addEventListener('resize', () => { measure(); snap(); });
document.addEventListener('visibilitychange', () => { lastT = null; });
reduce.addEventListener('change', () => { measure(); snap(); });
$$('.pic').forEach((pic, i) => {
const c = $('.scene').cloneNode(true);
c.setAttribute('aria-label', pic.dataset.alt);
pic.append(c);
pose(parts(c), [.62, 1.45, SF][i]);
});
measure(); snap();
addEventListener('load', () => {
measure(); snap();
setTimeout(() => { if (!acted && !reduce.matches && scrollY < 2) play(); }, 700);
});
</script>
</body>
</html>