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 color that sweeps across the headline</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;--stage:#0b0b0f;--ink:#f4f4f2;--soft:#c3c4d0;--muted:#a3a4b4;color-scheme:dark}
@supports(height:100svh){:root{--H:100svh}}
*{box-sizing:border-box;margin:0}
html{background:var(--stage);overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#3c3c4a var(--stage)}
body{color:var(--muted);font:400 clamp(15px,.5vw + 12px,18px)/1.6 'Schibsted Grotesk',system-ui,-apple-system,'Segoe UI',sans-serif;-webkit-font-smoothing:antialiased}
p{text-wrap:pretty}
.pg{width:min(34em,100%);min-height:var(--H);margin:0 auto;padding:clamp(24px,6vh,56px) clamp(18px,5vw,40px);display:grid;align-content:center;gap:clamp(10px,2.4vh,18px)}
.pg:first-child{padding-top:max(48px,clamp(24px,6vh,56px))} /* the page's Our version label sits over the top left corner of the frame */
.pg h2{font-size:clamp(20px,1.6vw + 14px,30px);line-height:1.2;font-weight:700;letter-spacing:-.01em;color:var(--ink);text-wrap:balance}
.eyebrow{font-size:13px;line-height:1.3;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:#8d8ea2}
.last{min-height:var(--H);padding:clamp(20px,5vh,48px) clamp(16px,5vw,40px) 14px;display:grid;grid-template-rows:1fr auto;justify-items:center;text-align:center}
.mid{align-self:center;max-width:100%;display:grid;justify-items:center;gap:clamp(8px,1.6vh,14px)}
.lede{max-width:28em;color:var(--soft)}
.fine{font-size:13px;color:#8d8ea2}
/* the headline. Armed, it is hidden: the text is drawn white on black and multiplied with a wide gradient behind it, so each letter takes the
gradient's color; a flat layer of the stage color on top (lightest wins) hides the black around the letters. Only the gradient moves.
The layers sit inside one another (stage layer, then black, then gradient, each a pixel or two in) so no edge of one shows through. */
.hl{--hs:clamp(26px,min(10vw,calc(var(--H) * .17)),88px);position:relative;isolation:isolate;overflow:hidden;width:fit-content;max-width:100%;padding:3px}
.hl h1{position:relative;padding:.12em .1em .18em;font-size:var(--hs);line-height:1.04;font-weight:800;letter-spacing:-.028em;color:var(--ink);text-wrap:balance}
.gw{display:none}
.armed h1{background:#000;color:#fff;mix-blend-mode:multiply}
.armed .gw{display:block;position:absolute;inset:4px;z-index:-1;overflow:hidden}
.gw i{position:absolute;top:0;bottom:0;left:0;width:512%;transform:translateX(-80.08%);will-change:transform;
background:linear-gradient(90deg,#f4f4f2 19.53%,#ffe9b8 35.16%,#ffce5a 43.95%,#ff9d5c 49.8%,#ff6f8b 54.69%,#b98cff 60.55%,#3a2872 66.02%,#000 70.31%)}
.armed::after{content:"";position:absolute;inset:0;background:var(--stage);mix-blend-mode:lighten}
.go .gw i{animation:sweep 3.23s linear .2s forwards}
.done h1{background:none;color:var(--ink);mix-blend-mode:normal}
.done .gw,.done::after{display:none}
@keyframes sweep{from{transform:translateX(-80.08%)}to{transform:none}}
@media(prefers-reduced-motion:reduce),(forced-colors:active){
.armed h1{background:none;color:var(--ink);mix-blend-mode:normal}
.armed .gw,.armed::after{display:none}
}
</style>
</head>
<body>
<main>
<section class="pg">
<p class="eyebrow">Field notes</p>
<h2>A slow week by the water</h2>
<p>The ferry leaves at seven and comes back at dusk. In between, the harbor belongs to gulls, nets and the people who mend them.</p>
<p>Most days begin the same way: a cup of tea, a walk along the pier and a long look at the sky, to guess what the afternoon will bring.</p>
</section>
<section class="pg">
<p class="eyebrow">Mid-morning</p>
<p>Down the lane, the bakery opens its shutters. The smell of warm bread reaches the corner long before the door does.</p>
<p>A boy delivers the newspapers on a bicycle that is a little too big for him. He knows every house by its gate.</p>
<p>By noon the benches fill with neighbors, and the talk drifts from weather to tides to whose turn it is to host dinner.</p>
</section>
<section class="last">
<div class="mid">
<p class="eyebrow">A closer look</p>
<div class="hl"><i class="gw" aria-hidden="true"><i></i></i><h1>Your headline,<br>in color.</h1></div>
<p class="lede">A short paragraph sits under the headline and stays still. Only the large letters take the color, once.</p>
</div>
<p class="fine">More notes follow on the next page.</p>
</section>
</main>
<script>
const $ = s => document.querySelector(s);
const reduce = matchMedia('(prefers-reduced-motion: reduce)'), FRAME = 1000 / 60, hl = $('.hl'), cl = hl.classList;
const blend = CSS.supports('mix-blend-mode', 'multiply');
let END = 0, raf = 0, lastT = null, playing = false, pos = 0, acted = false;
const measure = () => { END = Math.max(0, document.documentElement.scrollHeight - innerHeight); };
const arm = () => { cl.remove('go', 'done'); cl.add('armed'); }; // hidden, ready to play
const calm = () => cl.remove('armed', 'go', 'done'); // the plain headline, no sweep
const late = () => hl.getBoundingClientRect().top < innerHeight * .88; // risen into the window (or already past it)
const rearm = () => { if (!reduce.matches && blend) arm(); }; // Back to top and a run from the top start fresh
// The sweep starts by itself the first time the headline rises into the window, and stays played when you scroll back or wheel to the top.
// Reading reduce.matches can use up its change event, so this runs on every scroll and settles the state from the setting as it is now.
function check() {
if (reduce.matches || !blend) { calm(); return; }
if (!cl.contains('armed')) { if (scrollY < 2 || hl.getBoundingClientRect().top >= innerHeight) arm(); return; } // the first arm, or motion is allowed again
if (!cl.contains('go') && late()) cl.add('go');
}
hl.addEventListener('animationend', e => { if (e.animationName === 'sweep') cl.add('done'); });
function tick(ts) {
raf = 0;
const dt = lastT === null ? 0 : Math.min(ts - lastT, 50);
lastT = ts;
if (playing && Math.abs(scrollY - pos) > 2) playing = false; // the visitor moved it
if (playing) {
pos = Math.min(END, pos + END / 360 * (dt / FRAME)); // the whole scroll in 6 s
scrollTo({ top: pos, behavior: 'instant' });
if (pos >= END) playing = false;
}
if (playing) raf = requestAnimationFrame(tick); else lastT = null;
}
function play() {
measure();
if (END <= 0) return;
if (scrollY >= END - 2) scrollTo({ top: 0, behavior: 'instant' });
if (scrollY < 2) rearm(); // a run from the top starts fresh
pos = scrollY; playing = true; lastT = null;
if (!raf) raf = requestAnimationFrame(tick);
}
function toTop() { playing = false; scrollTo({ top: 0, behavior: 'instant' }); rearm(); }
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', check, { passive: true });
addEventListener('resize', () => { measure(); check(); });
document.addEventListener('visibilitychange', () => { lastT = null; });
reduce.addEventListener('change', check); // check() never hides a headline that is already in view
measure(); check();
addEventListener('load', () => {
measure(); check();
setTimeout(() => { if (!acted && !reduce.matches && scrollY < 2) play(); }, 700);
});
</script>
</body>
</html>