Stepped Story Scroll
Scroll through four text steps while a sticky diagram updates to match the step in view.
AI prompt
Explainer web page layout in a scrollytelling style: on the left a column of four short text steps with the current one in dark text and the others faded, on the right a sticky diagram showing four boxes in a row connected by arrows, Browser, CDN, Server and Database, the current step's box highlighted in blue and the arrow leading to it drawn solid, step numbers in small circles, light theme, flat vector style, generous spacing. Negative: gradients, shadows, text errors, clutter. Reduced motion: static layout.About this pattern
Definition
Scrollytelling pairs a visual that stays in place with text steps that scroll past. An observer watches which step is in view and updates the visual to match, so the reader controls the pace of the explanation by scrolling.
When to use it
- Keep the visual sticky and change only its state, not its layout.
- Make each step short, with one idea each.
- Mark the active step clearly and fade the others.
- Offer Next and Previous buttons so keyboard users and people who dislike scroll-jacking can move through the story.
What the controls do
- A scrolling text column with a sticky diagram, plus Previous and Next buttons.
Motion & timing
- The active node highlights over 250ms.
- Reduced motion: highlight without transition and scroll without smooth effects.
Tips & variations
- Never hijack scrolling; let the page scroll naturally.
- Provide the full text in order so it works without the visual.
Code of this live preview
<div class="bx"><div class="sg"><div class="tx" id="tx" tabindex="0" aria-label="Story steps"></div><div class="vz" id="vz" aria-hidden="true"></div></div><div class="two"><button class="mini" id="pv" type="button">Previous</button><button class="mini" id="nx" type="button">Next</button></div><p class="out" id="out" role="status"></p></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.sg{display:grid;grid-template-columns:1fr 92px;gap:10px;height:150px}.tx{overflow-y:auto;border:1px solid var(--line);border-radius:12px;background:var(--surface);scroll-snap-type:y proximity}.tx section{min-height:150px;padding:14px 12px;display:grid;align-content:center;gap:4px;font-size:12.5px;opacity:.35;transition:opacity .25s;scroll-snap-align:start}.tx section.on{opacity:1}.tx b{font-size:13.5px}.vz{display:grid;gap:5px;align-content:center}.vz span{height:28px;border-radius:8px;border:1px solid var(--line);background:var(--surface);display:grid;place-items:center;font-size:11px;font-weight:600;transition:background .25s,color .25s,border-color .25s}.vz span.on{background:#2b59d6;color:#fff;border-color:#2b59d6}.vz span.d{background:#dbe4fb;border-color:#b6c7f3}
.mini{height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;font-weight:600;cursor:pointer}.mini:disabled{opacity:.4;cursor:default}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}@media (prefers-reduced-motion:reduce){.tx section,.vz span{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const ST=[['Browser','You enter a web address and the browser asks for the page.'],['CDN','A nearby cache answers if it already has a copy, which is fast.'],['Server','If not, the request goes on to the origin server to build the page.'],['Database','The server reads the data it needs and the result flows back.']],tx=document.getElementById('tx'),vz=document.getElementById('vz'),calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let cur=0;
tx.innerHTML=ST.map((s,i)=>'<section data-i="'+i+'"><b>'+(i+1)+'. '+s[0]+'</b><span>'+s[1]+'</span></section>').join('');vz.innerHTML=ST.map(s=>'<span>'+s[0]+'</span>').join('');
function set(i){cur=i;[...tx.children].forEach((c,k)=>c.classList.toggle('on',k===i));[...vz.children].forEach((c,k)=>{c.classList.toggle('on',k===i);c.classList.toggle('d',k<i);});document.getElementById('out').textContent='Step '+(i+1)+' of 4: '+ST[i][0]+'.';}
const io=new IntersectionObserver(es=>{es.forEach(e=>{if(e.isIntersecting)set(+e.target.dataset.i);});},{root:tx,threshold:.6});[...tx.children].forEach(c=>io.observe(c));
function go(i){i=Math.max(0,Math.min(3,i));tx.children[i].scrollIntoView({behavior:calm?'auto':'smooth',block:'nearest'});set(i);}
document.getElementById('nx').addEventListener('click',()=>go(cur+1));document.getElementById('pv').addEventListener('click',()=>go(cur-1));set(0);One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Stepped Story Scroll — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.sg{display:grid;grid-template-columns:1fr 92px;gap:10px;height:150px}.tx{overflow-y:auto;border:1px solid var(--line);border-radius:12px;background:var(--surface);scroll-snap-type:y proximity}.tx section{min-height:150px;padding:14px 12px;display:grid;align-content:center;gap:4px;font-size:12.5px;opacity:.35;transition:opacity .25s;scroll-snap-align:start}.tx section.on{opacity:1}.tx b{font-size:13.5px}.vz{display:grid;gap:5px;align-content:center}.vz span{height:28px;border-radius:8px;border:1px solid var(--line);background:var(--surface);display:grid;place-items:center;font-size:11px;font-weight:600;transition:background .25s,color .25s,border-color .25s}.vz span.on{background:#2b59d6;color:#fff;border-color:#2b59d6}.vz span.d{background:#dbe4fb;border-color:#b6c7f3}
.mini{height:30px;padding:0 14px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:12px;font-weight:600;cursor:pointer}.mini:disabled{opacity:.4;cursor:default}.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}@media (prefers-reduced-motion:reduce){.tx section,.vz span{transition:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="sg"><div class="tx" id="tx" tabindex="0" aria-label="Story steps"></div><div class="vz" id="vz" aria-hidden="true"></div></div><div class="two"><button class="mini" id="pv" type="button">Previous</button><button class="mini" id="nx" type="button">Next</button></div><p class="out" id="out" role="status"></p></div>
</div>
<script>
const ST=[['Browser','You enter a web address and the browser asks for the page.'],['CDN','A nearby cache answers if it already has a copy, which is fast.'],['Server','If not, the request goes on to the origin server to build the page.'],['Database','The server reads the data it needs and the result flows back.']],tx=document.getElementById('tx'),vz=document.getElementById('vz'),calm=matchMedia('(prefers-reduced-motion:reduce)').matches;let cur=0;
tx.innerHTML=ST.map((s,i)=>'<section data-i="'+i+'"><b>'+(i+1)+'. '+s[0]+'</b><span>'+s[1]+'</span></section>').join('');vz.innerHTML=ST.map(s=>'<span>'+s[0]+'</span>').join('');
function set(i){cur=i;[...tx.children].forEach((c,k)=>c.classList.toggle('on',k===i));[...vz.children].forEach((c,k)=>{c.classList.toggle('on',k===i);c.classList.toggle('d',k<i);});document.getElementById('out').textContent='Step '+(i+1)+' of 4: '+ST[i][0]+'.';}
const io=new IntersectionObserver(es=>{es.forEach(e=>{if(e.isIntersecting)set(+e.target.dataset.i);});},{root:tx,threshold:.6});[...tx.children].forEach(c=>io.observe(c));
function go(i){i=Math.max(0,Math.min(3,i));tx.children[i].scrollIntoView({behavior:calm?'auto':'smooth',block:'nearest'});set(i);}
document.getElementById('nx').addEventListener('click',()=>go(cur+1));document.getElementById('pv').addEventListener('click',()=>go(cur-1));set(0);
</script>
</body></html>