AI CSS Animations

Infinite Scrolling Text

Big display words scroll endlessly, alternating solid and outlined, with star separators and edges that fade out. Two copies move by one copy's width, so the loop point never shows.

Also known as: infinite scrolling text css, big text marquee, scrolling headline loop.

Design✦Build✦Launch✦

HTML

<div class="txt-infinite-scrolling-text">
  <div class="txt-infinite-scrolling-text-group">
    <span>Design</span><i>✦</i><span>Build</span><i>✦</i><span>Launch</span><i>✦</i>
  </div>
  <div class="txt-infinite-scrolling-text-group" aria-hidden="true">
    <span>Design</span><i>✦</i><span>Build</span><i>✦</i><span>Launch</span><i>✦</i>
  </div>
</div>

CSS

.txt-infinite-scrolling-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;
  width: 14em;
  overflow: hidden;
  white-space: nowrap;
  color: var(--c);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);}
.txt-infinite-scrolling-text-group {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  font-size: 1.5em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  animation: txt-infinite-scrolling-text-scroll 9s linear infinite;
}
.txt-infinite-scrolling-text-group span:nth-of-type(even) {
  color: transparent;
  -webkit-text-stroke: 0.03em var(--c);
}
.txt-infinite-scrolling-text-group i {
  padding: 0 0.35em;
  font-size: 0.5em;
  font-style: normal;
  color: color-mix(in srgb, var(--c) 70%, transparent);
}
@keyframes txt-infinite-scrolling-text-scroll {
  to { transform: translateX(-100%); }
}

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