AI CSS Animations

Flipping Letters Animation

Letters spin a full turn on their vertical axis one after another, like coins flipped down a row, then rest. Each letter carries its own perspective() so the flip has depth without a wrapper.

Also known as: letter flip animation, rotating letters css, 3d flip text loop.

HTML

<div class="txt-flipping-letters" aria-label="Flip side"><span aria-hidden="true"><span style="--i: 0">F</span><span style="--i: 1">l</span><span style="--i: 2">i</span><span style="--i: 3">p</span><span style="--i: 4">&nbsp;</span><span style="--i: 5">s</span><span style="--i: 6">i</span><span style="--i: 7">d</span><span style="--i: 8">e</span></span></div>

CSS

.txt-flipping-letters {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--c);}
.txt-flipping-letters span span {
  display: inline-block;
  animation: txt-flipping-letters-flip 3s cubic-bezier(0.65, 0, 0.35, 1) infinite;
  animation-delay: calc(var(--i) * 0.1s);
}
@keyframes txt-flipping-letters-flip {
  0%, 12%   { transform: perspective(3em) rotateY(0); }
  42%, 100% { transform: perspective(3em) rotateY(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-flipping-letters, .txt-flipping-letters *, .txt-flipping-letters::before, .txt-flipping-letters::after, .txt-flipping-letters *::before, .txt-flipping-letters *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar text animations