AI CSS Animations

Split Flap Display Text

Letters rattle through the alphabet on dark tiles and land one by one, like an airport departure board. Each tile counts with an alphabetic @counter-style, so no letters are hard-coded in CSS.

Also known as: solari board css, departure board animation, airport board text.

HTML

<div class="txt-split-flap-text" aria-label="BOARDING"><span style="--to: 2; --n: 7"></span><span style="--to: 15; --n: 12"></span><span style="--to: 1; --n: 8"></span><span style="--to: 18; --n: 13"></span><span style="--to: 4; --n: 9"></span><span style="--to: 9; --n: 14"></span><span style="--to: 14; --n: 10"></span><span style="--to: 7; --n: 15"></span></div>

CSS

@counter-style txt-split-flap-text-abc {
  system: cyclic;
  symbols: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z;
}
@property --txt-split-flap-text-k {
  syntax: "<integer>";
  initial-value: 0;
  inherits: false;
}
.txt-split-flap-text {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 1.25);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  display: inline-flex;
  gap: 0.08em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --step: 70ms;}
.txt-split-flap-text span {
  position: relative;
  width: 0.86em;
  height: 1.3em;
  line-height: 1.3em;
  text-align: center;
  color: #f8fafc;
  background: linear-gradient(color-mix(in srgb, var(--c) 18%, #1f2937) 50%, color-mix(in srgb, var(--c) 18%, #111827) 50%);
  border-radius: 0.1em;
  perspective: 2em;
  counter-reset: txt-split-flap-text-l var(--txt-split-flap-text-k);
  /* --to is the letter (A = 1), --n how many flaps fall before it lands */
  animation: txt-split-flap-text-count calc(var(--n) * var(--step)) steps(var(--n)) forwards;
}
.txt-split-flap-text span::before {
  content: counter(txt-split-flap-text-l, txt-split-flap-text-abc);
}
/* the hinge and a falling flap that ticks once per letter */
.txt-split-flap-text span::after {
  content: "";
  position: absolute;
  inset: 0 0 50%;
  border-bottom: 0.03em solid rgb(0 0 0 / 0.5);
  border-radius: 0.1em 0.1em 0 0;
  background: linear-gradient(rgb(255 255 255 / 0.08), rgb(0 0 0 / 0.35));
  transform-origin: bottom;
  animation: txt-split-flap-text-flap var(--step) ease-in var(--n) forwards;
}
@keyframes txt-split-flap-text-count {
  from { --txt-split-flap-text-k: calc(var(--to) + 26 - var(--n)); }
  to   { --txt-split-flap-text-k: calc(var(--to) + 26); }
}
@keyframes txt-split-flap-text-flap {
  from { transform: rotateX(0); }
  to   { transform: rotateX(-90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-split-flap-text, .txt-split-flap-text *, .txt-split-flap-text::before, .txt-split-flap-text::after, .txt-split-flap-text *::before, .txt-split-flap-text *::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