Skip to content
animorio
IT
Back to the library

Stacking cards

Scroll, SVGGSAP, CSS onlyEasyCompressed weight: Demo 4.1 KBGSAP + ScrollTrigger 45 KBFreeDownload the zip

Scroll inside the preview

As you scroll, each card stops at the top and the next climbs over it: the one below shrinks, tilts and darkens, and each drawing traces itself.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Stacking cards" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Stacking cards</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/standard.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main>
    <section class="apertura">
      <p class="sopra">How an animation is born</p>
      <p class="grande">Scroll: each card stops at the top, the next one slides over it and the one below shrinks and tilts.</p>
    </section>

    <section class="pila">
      <div class="pila__carte">
      <span class="ancora" aria-hidden="true"></span>
      <article class="carta c1" style="--i: 0">
        <div class="carta__testo">
          <h2 class="carta__titolo">The sketch</h2>
          <p>It starts on paper: what has to happen, in what order, for whoever is watching.</p>
          <ul class="etichette"><li>the story</li><li>the moments</li><li>the gesture</li></ul>
        </div>
        <svg class="disegno" viewBox="0 0 244 180" aria-hidden="true">
        <path class="tratto" d="M22 132 C 60 60, 100 150, 140 90 S 200 40, 222 70" />
        <path class="tratto" d="M168 28 l30 30 -86 86 -34 6 6 -34 z" />
        <path class="tratto" d="M144 52 l30 30" />
        <path class="tratto compare" d="M60 40 l12 16 -12 16 -12 -16 z" />
        </svg>
        <span class="carta__velo" aria-hidden="true"></span>
      </article>
      <span class="ancora" aria-hidden="true"></span>
      <article class="carta c2" style="--i: 1">
        <div class="carta__testo">
          <h2 class="carta__titolo">The timing</h2>
          <p>Every gesture has a length and a place on the timeline: nothing happens all at once.</p>
          <ul class="etichette"><li>durations</li><li>staggers</li><li>pauses</li></ul>
        </div>
        <svg class="disegno" viewBox="0 0 244 180" aria-hidden="true">
        <path class="tratto" d="M20 110 H224" />
        <path class="tratto" d="M20 100 v20 M71 104 v12 M122 100 v20 M173 104 v12 M224 100 v20" />
        <path class="tratto compare" d="M46 66 l12 16 -12 16 -12 -16 z" />
        <path class="tratto compare" d="M122 50 l14 18 -14 18 -14 -18 z" />
        <path class="tratto compare" d="M198 66 l12 16 -12 16 -12 -16 z" />
        <path class="tratto" d="M46 150 H198" />
        </svg>
        <span class="carta__velo" aria-hidden="true"></span>
      </article>
      <span class="ancora" aria-hidden="true"></span>
      <article class="carta c3" style="--i: 2">
        <div class="carta__testo">
          <h2 class="carta__titolo">The curve</h2>
          <p>Real motion never goes straight: it starts slow, speeds up, brakes. The curve decides the character.</p>
          <ul class="etichette"><li>easing</li><li>springs</li><li>bounces</li></ul>
        </div>
        <svg class="disegno" viewBox="0 0 244 180" aria-hidden="true">
        <path class="tratto" d="M24 150 C 120 150, 110 36, 220 34" />
        <path class="tratto" d="M24 150 L96 150 M220 34 L150 34" />
        <path class="tratto compare" d="M90 144 h12 v12 h-12 z" />
        <path class="tratto compare" d="M144 28 h12 v12 h-12 z" />
        <path class="tratto" d="M24 20 V150 H230" />
        </svg>
        <span class="carta__velo" aria-hidden="true"></span>
      </article>
      <span class="ancora" aria-hidden="true"></span>
      <article class="carta c4" style="--i: 3">
        <div class="carta__testo">
          <h2 class="carta__titolo">The launch</h2>
          <p>Try it on a phone, try it with reduced motion, then publish it and watch who comes by.</p>
          <ul class="etichette"><li>tests</li><li>the phone</li><li>the release</li></ul>
        </div>
        <svg class="disegno" viewBox="0 0 244 180" aria-hidden="true">
        <path class="tratto" d="M20 30 h204 v126 h-204 z" />
        <path class="tratto" d="M20 54 H224" />
        <path class="tratto" d="M36 42 h40" />
        <path class="tratto compare riempi" d="M104 78 l48 28 -48 28 z" />
        </svg>
        <span class="carta__velo" aria-hidden="true"></span>
      </article>
      </div>
      <div class="pila__coda" aria-hidden="true"></div>
    </section>

    <section class="coda">
      <p class="grande">Four cards, one stack. Scroll back up and do it again.</p>
    </section>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/ScrollTrigger.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

31 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Stacking cards” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

Four coloured cards tell a process. As you scroll, the first stops at the top; the second climbs and settles on it, one step lower, while the first gets slightly smaller, tilts by a degree and darkens, like a sheet ending up under the pile. Each card has a line drawing that traces itself when the card reaches its place. At the end the pile stays still for a moment, complete.

How it works

Sticky, one step lower

The cards are position: sticky with top = offset + index × step (16 pixels): each stops just below the previous one and leaves its edge visible.

The anchors

Before every card there is a zero-height span. Triggers attach to it and not to the card, because a sticky card changes position while it is stuck and ScrollTrigger’s maths would go wrong.

Under the pile

With scrub, while the next card rises from the bottom to its step, the one below goes to scale 0.93, rotates ±1.4 degrees (one direction per card) and a dark veil rises over it up to 0.38.

The drawing that traces itself

Every SVG stroke takes its length with getTotalLength and starts with stroke-dashoffset equal to that length; when the card arrives the offset goes to zero and the stroke draws. Small pieces pop out with back.out.

Values to change

NameFileDefaultWhat it changes
--alto / --scalinostyle.css12vh / 16pxWhere the first card stops and how much each one sticks out from the previous.
PICCOLAscript.js0.93The scale of the covered card.
STORTAscript.js1.4The degrees of rotation of the covered card.
BUIOscript.js0.38How much the covered card darkens.

Try them in the Playground

When to use it

For a three-to-six step process, a method, the phases of a job: the pile makes each step feel like it rests on the previous one. With more than six cards the run gets long.

On phones

The cards stack text over drawing, with the same minimum height for all, and the step shrinks to 10 pixels.

With reduced motion

The cards stay sticky but do not shrink or tilt; the drawings are already traced.

Pitfalls

  • Do not use the sticky card as a trigger: while stuck it changes position and start/end go wrong. Put a zero-height anchor before each card.
  • An overflow hidden on a parent of the pile breaks sticky: if you need to clip something sideways use overflow: clip.
  • All cards should have the same height, otherwise a short card shows the one below in full.
  • Leave an empty space after the last card: without it the pile leaves as soon as it is complete and nobody sees it whole.

Libraries

GSAP 3.15.0, ScrollTrigger (GSAP) 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 4.1 KB; the libraries: GSAP + ScrollTrigger 45 KB.

Testing

Tested on 21 October 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: Done

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations