CSS Flashcard Flip Card

A study flashcard that flips vertically on click or tap, driven by a hidden checkbox so it works on touch.

  • flashcard
  • flip
  • click
  • tap
  • checkbox
  • quiz
  • study
HTML
<label class="flashcard">
  <input type="checkbox" aria-label="Flip card to show the answer">
  <span class="flashcard-inner">
    <span class="flashcard-face">
      <small>Question</small>
      What does CSS stand for?
    </span>
    <span class="flashcard-face flashcard-back">
      <small>Answer</small>
      Cascading Style Sheets
    </span>
  </span>
</label>
CSS
.flashcard {
  display: block;
  width: 240px;
  height: 140px;
  font-family: system-ui, sans-serif;
  perspective: 800px;
  cursor: pointer;
}

.flashcard input {
  position: absolute;
  opacity: 0;
}

.flashcard-inner {
  position: relative;
  display: block;
  height: 100%;
  border-radius: 16px;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.3, 1.3, 0.5, 1);
}

.flashcard input:checked + .flashcard-inner {
  transform: rotateX(180deg);
}

.flashcard input:focus-visible + .flashcard-inner {
  outline: 3px solid #0891b2;
  outline-offset: 4px;
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 16px;
  border-radius: inherit;
  background: #fff;
  box-shadow: 0 10px 24px -10px rgba(8, 145, 178, 0.45);
  color: #164e63;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.flashcard-face small {
  color: #0891b2;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.flashcard-back {
  background: #0891b2;
  color: #fff;
  transform: rotateX(180deg);
}

.flashcard-back small {
  color: #cffafe;
}

@media (prefers-reduced-motion: reduce) {
  .flashcard-inner {
    transition: none;
  }
}

About this CSS Flashcard Flip Card

This CSS Flashcard Flip Card is 72 lines of pure CSS (1.3 KB) with no JavaScript and no dependencies. It uses transitions, 3D transforms, transforms and box shadows. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #0891b2
  • #fff
  • #164e63
  • #cffafe

How to use this flashcard flip card

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .flashcard class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback