AI CSS Animations

Rolling Wave Text

Every letter traces a small circle a little behind its neighbor, the way water moves under a passing swell. Rotate, translate, rotate back: the letter circles without ever tilting.

Also known as: wavy text animation css, letters moving in circles, water wave text.

HTML

<div class="txt-rolling-wave-text" aria-label="Out at sea"><span aria-hidden="true"><span style="--i: 0">O</span><span style="--i: 1">u</span><span style="--i: 2">t</span><span style="--i: 3">&nbsp;</span><span style="--i: 4">a</span><span style="--i: 5">t</span><span style="--i: 6">&nbsp;</span><span style="--i: 7">s</span><span style="--i: 8">e</span><span style="--i: 9">a</span></span></div>

CSS

.txt-rolling-wave-text {
  --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-rolling-wave-text span span {
  display: inline-block;
  animation: txt-rolling-wave-text-roll 2.4s linear infinite;
  animation-delay: calc(var(--i) * 0.2s - 2.4s);
}
@keyframes txt-rolling-wave-text-roll {
  from { transform: rotate(0deg) translateX(0.14em) rotate(0deg); }
  to   { transform: rotate(360deg) translateX(0.14em) rotate(-360deg); }
}

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