AI CSS Animations

Wave Text

The letters ride a wave, each one rising a beat after its neighbor. The delay comes from the per-letter index, so any word works without touching the CSS.

Also known as: wavy text, bouncing letters, letter wave animation.

Wavy text

HTML

<div class="txt-wave" aria-label="Wavy text"><span style="--i: 0">W</span><span style="--i: 1">a</span><span style="--i: 2">v</span><span style="--i: 3">y</span><span style="--i: 4">&nbsp;</span><span style="--i: 5">t</span><span style="--i: 6">e</span><span style="--i: 7">x</span><span style="--i: 8">t</span></div>

CSS

.txt-wave {
  --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-wave span {
  display: inline-block;
  animation: txt-wave-rise 1.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * 80ms);
}
@keyframes txt-wave-rise {
  0%, 40%, 100% { transform: translateY(0); }
  20%           { transform: translateY(-0.35em); }
}

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