3D Flip Sequence
A row of cards that flip in a cascade: one click, and each card makes its half-turn in 3D two tenths of a second after the previous one. Three cards in 0.8 s, the order set by a CSS variable, the way back on the next click. CSS 3D and 1.3 KB of JavaScript.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Transitions has 52 effects, including 9 free. Explore the category →
3 usage examples



How it works
The .fsq-seq row holds three .fsq-card elements of 60 × 80 px, each with a front .fsq-front and a back .fsq-back set back to back. The whole row is what you click (224 × 104 px with its padding): the script adds or removes the .fsq-on class on it, nothing more. All the motion is a CSS transition, rotateY(180deg) in 0.4 s on each card.
The cascade comes from a variable. Each card carries its rank in --fsq-i (0, 1, 2), and its transition delay is that rank times 0.2 s. Read frame by frame: at 200 ms the first card is at 65° and the other two have not moved; at 400 ms it is done and the second is at 65°; at 600 ms it is the third one's turn; at 800 ms everything is flipped. On the next click, the cards come back in the same order, the first one first.
Each face is only drawn during its half of the half-turn: a second transition, on visibility, switches exactly when the card is edge-on (0.2 s after it starts). So the back appears at the right moment even in an engine that handles back faces poorly in 3D. And since these are transitions, nothing is locked: two clicks 120 ms apart bring the cards back to the front from the angle reached, with no jump.
Accessibility
- Keyboard: the row carries
role="button"andtabindex="0". Tab reaches it, Enter and Space flip it without scrolling the page; 2 px pink outline, offset by 4 px, around the row. - Screen readers:
aria-pressedfollows the state, and the script hides the faces not shown witharia-hidden. So the button is named by the visible faces ("A B C", then "1 2 3" in the demo). The swap happens on click, before the last card has turned. If that content does not say what the button does, add anaria-labelto the row. - Reduced motion: no rotation and no cascade, the backs show at once (all cards flipped 60 ms after the click). The function is intact.
- By finger: the target is the whole row; a single card cannot be flipped. Nothing depends on hover.
- Card content: the row being a button, its cards cannot hold a link or another button. The demo's letters and digits, in 19 px bold, sit between 3.5:1 and 4.5:1 on their gradients: enough for large text, too tight for small text.
Browser compatibility
CSS 3D (transform-style: preserve-3d, perspective, backface-visibility with its -webkit- prefix), CSS variables inside a delay calc(), inset + 1.3 KB of JavaScript. Angles, face switch instants, interrupted half-turn, keyboard, emulated touch, decimal ranks and reduced motion give the same readings in Chromium 149 and Firefox 151. In the test WebKit 26.5, the same readings hold but the half-turn is drawn flat, with no perspective effect: Safari's 3D rendering could therefore not be checked. Floor set by inset: Chrome 87, Firefox 66, Safari 14.1.
Without JavaScript, the row stays on the fronts. In the test WebKit, which draws the rotation flat, the backs still show at the right instant thanks to the visibility switch: the content is never lost.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fsq-stage">
<div class="fsq-seq" role="button" tabindex="0" aria-pressed="false">
<div class="fsq-card" style="--fsq-i: 0;">
<div class="fsq-face fsq-front">…</div>
<div class="fsq-face fsq-back" aria-hidden="true">…</div>
</div>
<div class="fsq-card" style="--fsq-i: 1;">
<div class="fsq-face fsq-front">…</div>
<div class="fsq-face fsq-back" aria-hidden="true">…</div>
</div>
<div class="fsq-card" style="--fsq-i: 2;">
<div class="fsq-face fsq-front">…</div>
<div class="fsq-face fsq-back" aria-hidden="true">…</div>
</div>
</div>
<span class="fsq-hint">…</span>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Order and pace (HTML — --fsq-i in each card's style) |
0, 1, 2 from left to right | Rank need not follow position: give 0 to the card that must leave first. Decimals are allowed (0.5 = a start at 0.1 s, checked), and two cards with the same rank turn together. |
Cascade step (CSS — both .2s values multiplied by --fsq-i) |
0.2 s between two cards | It appears in the card's transition and in the faces' transition: change both, or the back shows too early or too late. |
Half-turn duration (CSS — transform .4s on .fsq-card, and + .2s on the faces) |
0.4 s | The second value must stay half of the first: it is the instant when the card is edge-on and the faces swap. |
Card size (CSS — .fsq-card { width; height }, gap of .fsq-seq) |
60 × 80 px, 10 px apart | From a 46 px digit tile to a 100 px card. Beyond that, raise the perspective too, to keep a natural half-turn. |
Perspective (CSS — perspective of .fsq-seq) |
600 px | Shorter, the rotation is dramatic and edge cards distort; at 900 px and more, it flattens and all cards turn almost alike. |
Starting state (HTML — fsq-on class on .fsq-seq) |
absent: fronts | With the class, the row opens on the backs, with no animation; the script reads that state on load and sets aria-pressed and the aria-hidden values accordingly. |
FAQ
.fsq-seq, which flips all its cards. For independent cards, give each its own one-card row; the script arms every .fsq-seq on the page separately, like the three lines of the price board in the example, each with its own state.perspective to 900 px or more.