AI CSS Animations

Letters Pop In

Letters pop in from nothing with a springy overshoot, one after another. The overshoot comes from a cubic-bezier that goes past 1, so no keyframe juggling is needed.

Also known as: bounce in letters, elastic text, scale in letters.

Surprise!

HTML

<div class="txt-letters-pop" aria-label="Surprise!"><span style="--i: 0">S</span><span style="--i: 1">u</span><span style="--i: 2">r</span><span style="--i: 3">p</span><span style="--i: 4">r</span><span style="--i: 5">i</span><span style="--i: 6">s</span><span style="--i: 7">e</span><span style="--i: 8">!</span></div>

CSS

.txt-letters-pop {
  --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-letters-pop span {
  display: inline-block;
  transform: scale(0);
  animation: txt-letters-pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: calc(var(--i) * 50ms);
}
@keyframes txt-letters-pop-in {
  to { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .txt-letters-pop, .txt-letters-pop *, .txt-letters-pop::before, .txt-letters-pop::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