AI CSS Animations

Strikethrough Rotating Text

Each word gets crossed off: a line draws through it, the word fades back, then it lifts away for the next one. Reads like a to-do list being cleared, which suits 'no more...' and 'stop...' headlines.

Also known as: crossed out word animation, strike through text swap, no more words rotator.

No more meetings busywork chaos

HTML

<div class="txt-strikethrough-rotating-text">No more
  <span class="txt-strikethrough-rotating-text-words">
    <span style="--i: 0">meetings</span>
    <span style="--i: 1">busywork</span>
    <span style="--i: 2">chaos</span>
  </span>
</div>

CSS

.txt-strikethrough-rotating-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;
  display: flex;
  align-items: baseline;
  gap: 0.28em;
  white-space: nowrap;}
.txt-strikethrough-rotating-text-words {
  display: inline-grid;
}
.txt-strikethrough-rotating-text-words span {
  grid-area: 1 / 1;
  justify-self: start;
  position: relative;
  color: var(--c);
  /* 3 words x 2.6s = 7.8s */
  animation: txt-strikethrough-rotating-text-word 7.8s cubic-bezier(0.2, 0.7, 0.2, 1) infinite;
  animation-delay: calc(var(--i) * 2.6s - 8.3s);
}
.txt-strikethrough-rotating-text-words span::after {
  content: "";
  position: absolute;
  left: -0.06em;
  right: -0.06em;
  top: 52%;
  height: 0.09em;
  border-radius: 0.05em;
  background: var(--c);
  transform: scaleX(0);
  transform-origin: left;
  animation: txt-strikethrough-rotating-text-strike 7.8s cubic-bezier(0.6, 0, 0.3, 1) infinite;
  animation-delay: inherit;
}
.txt-strikethrough-rotating-text-words span:not(:first-child) {
  opacity: 0;
}
@keyframes txt-strikethrough-rotating-text-word {
  0%     { opacity: 0; transform: translateY(0.3em); color: var(--c); }
  4.49%  { opacity: 1; transform: translateY(0); }
  15.38% { color: var(--c); }
  20.51% { color: color-mix(in srgb, var(--c) 45%, transparent); }
  28.85% {
    opacity: 1; transform: translateY(0);
    animation-timing-function: cubic-bezier(0.5, 0, 0.75, 0);
  }
  33.33% { opacity: 0; transform: translateY(-0.3em); }
  100%   { opacity: 0; transform: translateY(0.3em); color: var(--c); }
}
@keyframes txt-strikethrough-rotating-text-strike {
  0%, 15.38% { transform: scaleX(0); }
  20.51%, 100% { transform: scaleX(1); }
}

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