webdevpuneet.com

Rolodex Flip Carousel — HTML CSS JS Snippet

Rolodex Flip Carousel · Carousels · Plain HTML, CSS & JS · Live preview

Copy & paste

Source Code

<div class="rfc-stage">
  <div class="rfc-card" id="rfcCard" style="background:linear-gradient(160deg,#6366f1,#4338ca)">
    <span class="rfc-icon">🎧</span><h3>Headphones</h3><p>Active noise cancelling, 40hr battery.</p>
  </div>
  <div class="rfc-controls">
    <button class="rfc-btn" id="rfcPrev" aria-label="Previous card">‹</button>
    <div class="rfc-dots" id="rfcDots"></div>
    <button class="rfc-btn" id="rfcNext" aria-label="Next card">›</button>
  </div>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month, 7 days free), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

A genuine two-phase 3D flip — flip-out then flip-in — not a single crossfade or slide transition
animationend listeners chain the two phases precisely, never relying on a guessed setTimeout duration
transform-origin: center top pivots the rotation around the card's top edge, matching a real rolodex page
perspective on the parent, preserve-3d and the pivot origin on the card, for genuine (not flat) 3D depth
An animating guard prevents overlapping flips if a user clicks rapidly mid-animation
Card content and background are swapped from a plain data array, generating matching dots automatically

About this UI Snippet

Rolodex Flip Carousel — Two Chained Animations, Not One Transition

Screenshot of the Rolodex Flip Carousel snippet rendered live

A slide carousel moves sideways; this one flips forward around its own top edge, like a page on a physical rolodex or day-planner falling away to reveal the next one. That motion can't be a single CSS transition between two states — it needs *two separate animations chained together*, because the outgoing card and the incoming card are travelling through completely different halves of the rotation.

Flip-out, swap content, flip-in — using animationend as the handoff

Clicking next adds .rfc-flip-out, a keyframe animation that rotates the card from flat to rotateX(-100deg) while fading it out — as if it's tipping forward and away. Only once that animation actually *finishes* (caught via an animationend listener, not a fixed setTimeout) does the code swap in the next card's content and add .rfc-flip-in, a second keyframe animation starting from rotateX(100deg) (as if the new card is falling into place from behind) down to flat. Two listeners, two animations, one continuous-feeling motion.

Why perspective lives on the parent, not the card

Just like the cube carousel, perspective: 900px sits on .rfc-stage (the card's parent) while transform-style: preserve-3d and transform-origin: center top live on the card itself — that origin is what makes the rotation pivot around the card's *top edge* specifically, producing the falling-page look rather than a rotation around the card's own center.

Step by step

How to Use

  1. 1
    Paste HTML, CSS, and JSA single card appears showing the first item.
  2. 2
    Click the next arrowThe card flips forward and away, then the next card falls into place from behind.
  3. 3
    Click a dotJump directly to that card — the same two-phase flip plays regardless of distance.
  4. 4
    Use arrow keysLeft/Right trigger the same flip without touching the mouse.
  5. 5
    Add a sixth cardAdd one object to the CARDS array — dots and flip logic scale automatically.

Real-world uses

Common Use Cases

Featured product or team spotlights
A tactile, physical-feeling way to page through a small set of highlighted items.
Quote or tip-of-the-day rotators
The falling-page motion reads as "turning to a new page," fitting for rotating short content.
Onboarding or feature intro cards
Walk through a handful of intro cards with a distinctive, memorable transition.
Learning chained CSS keyframe animations
A clean example of sequencing two animations via animationend rather than timing guesses.

Got questions?

Frequently Asked Questions

A setTimeout duplicates the animation-duration value in two places (the CSS and the JS), which drifts the moment either one is edited alone. animationend fires exactly when the browser finishes the animation, so the two phases always stay perfectly chained regardless of how long the animation actually takes.

Swap the rotateX direction in both keyframes — flip-out to rotateX(100deg) and flip-in starting from rotateX(-100deg) — to reverse which way the page appears to fall.

Yes — replace rotateX with rotateY throughout, and change transform-origin from center top to either left center or right center depending on which edge you want the page to pivot around.

Change the .45s duration on both .rfc-flip-out and .rfc-flip-in — keep them equal so the two phases feel balanced, or make flip-in slightly faster than flip-out for a snappier arrival.

The arrows and dots are real, labeled buttons, and the whole carousel is operable via Left/Right arrow keys — consider adding an aria-live region announcing the new card's title once the flip completes.