TransitionsPremium

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.

CSS 3DJSFlipSequence

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

Service station price board alternating pump price and card price — digits flip in a cascade — 3D Flip Sequence example 1

① Service station price board alternating pump price and card price — digits flip in a cascade

WhenAt the entrance of a village station, the board shows the prices of diesel and both unleaded fuels. Every few seconds, the twelve digits flip one after the other, top to bottom: the prices with the station card replace the pump prices, in green, then the reverse.
WhyA driver reads the board while moving. The cascade shows that the sign is changing without wiping the three prices at once: never more than four digits out of twelve are moving at a time.
SettingsThree .fsq-seq rows of four 46 × 62 px cards. Ranks are decimal and run on from one row to the next (0 to 1.5, then 2 to 3.5, then 4 to 5.5): one digit leaves every 0.1 s and the whole board changes in 1.5 s. The rows are made unclickable with pointer-events: none, it is a display. In the capture, the scene triggers the three rows through row.click(), twice; on a real board, a timer would.
Podium revealed step by step — a village soapbox derby — 3D Flip Sequence example 2

② Podium revealed step by step — a village soapbox derby

WhenEnd of the final. On the refreshment stand's screen, three dark cards: 2nd, 1st, 3rd. The announcer presses "Reveal the podium": bronze flips and gives The Ever-Rollers, then silver, and only after that, in the middle, the winners and their time.
WhyA podium's order is not reading order: the middle card must turn last. Here the order is a setting on each card, independent of its place, which builds suspense without a line of script.
SettingsThree 100 × 128 px cards (148 px for the middle one), perspective raised to 900 px. --fsq-i ranks: 2 for silver on the left, 4 for gold in the center, 0 for bronze on the right, that is a start at 0 s, 0.4 s and 0.8 s, and 1.2 s in all. The orange button belongs to the scene: it passes its click on to the row, which stays clickable too. In the capture, the real mouse click lands on that button.
Trail marks to flip over to read their meaning — "Staying on the trail" page of a hiking club — 3D Flip Sequence example 3

③ Trail marks to flip over to read their meaning — "Staying on the trail" page of a hiking club

WhenBefore a first outing, a new member reads the club's page. Four marks painted on a bark background: he tries to guess, then clicks the row. The cards flip from left to right: right way, turn ahead, wrong way, local loop.
WhyThe four answers come one by one, in reading order: there is time to check each before the next one lands, which a simultaneous flip does not allow.
SettingsFour 86 × 100 px cards, ranks 0 to 3: 1 s for the whole row. The marks are drawn in CSS on the fronts, with role="img" and an aria-label describing them; the backs carry the meaning as text. No scene script: in the capture, the real mouse click lands on the row.

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" and tabindex="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-pressed follows the state, and the script hides the faces not shown with aria-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 an aria-label to 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.

Chrome 87+✓ Full (measured in Chromium 149)
Firefox 66+✓ Full (measured in Firefox 151)
Safari 14.1+✓ Works (test WebKit 26.5); 3D rendering not checked
Edge 87+✓ Full (Chromium engine)
Mobile iOS 14.5+✓ Not checked on a device
Android Chrome 87+✓ Full (emulated touch)

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):

index.html — structure
<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 / propertyDefaultEffect
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

Flip Transition flips one large 200 × 200 px card, in 0.8 s: one object, two faces. 3D Flip Sequence flips a whole row of small cards in one gesture, one after the other, and you choose the order and the number of cards without touching the script. The first suits an object you examine from both sides; the second a series that is revealed: digits, a ranking, answers.
No, not within one row: the click is listened for by .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.
Because perspective is declared once, on the row: there is a single vanishing point, at the center. The middle card is seen head-on, the edge ones slightly from the side, and their edge distorts more during the half-turn. That is what gives the feeling of a real row of objects in the same space. To lessen the gap on a long row, raise perspective to 900 px or more.