The word slides across and back while four fading copies trail behind it, spreading out at full speed and catching up when it stops. The copies share one keyframe with small delays.
Also known as: motion trail text css, ghost trail text, text afterimage animation.
<div class="txt-echo-trail-text"><span class="txt-echo-trail-text-word">ECHO</span><span class="txt-echo-trail-text-echoes" aria-hidden="true"><span style="--i: 1">ECHO</span><span style="--i: 2">ECHO</span><span style="--i: 3">ECHO</span><span style="--i: 4">ECHO</span></span></div>
.txt-echo-trail-text {
--c: var(--txt-color, #3b82f6);
font-size: calc(var(--txt-size, 32px) * 1.5);
font-family: system-ui, sans-serif;
font-weight: 900;
line-height: 1.2;
display: inline-grid;
color: var(--c);
letter-spacing: 0.04em;}
.txt-echo-trail-text-word,
.txt-echo-trail-text-echoes {
grid-area: 1 / 1;
}
.txt-echo-trail-text-word {
position: relative;
z-index: 1;
animation: txt-echo-trail-text-slide 2.8s cubic-bezier(0.76, 0, 0.24, 1) infinite;
}
.txt-echo-trail-text-echoes {
display: grid;
}
/* each copy runs the same path a little later and a little fainter */
.txt-echo-trail-text-echoes span {
grid-area: 1 / 1;
opacity: calc(0.55 - var(--i) * 0.11);
animation: txt-echo-trail-text-slide 2.8s cubic-bezier(0.76, 0, 0.24, 1) infinite backwards;
animation-delay: calc(var(--i) * 70ms);
}
@keyframes txt-echo-trail-text-slide {
0%, 12% { transform: translateX(-1.6em); }
50%, 62% { transform: translateX(1.6em); }
100% { transform: translateX(-1.6em); }
}
@media (prefers-reduced-motion: reduce) {
.txt-echo-trail-text, .txt-echo-trail-text *, .txt-echo-trail-text::before, .txt-echo-trail-text::after, .txt-echo-trail-text *::before, .txt-echo-trail-text *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--txt-color on the element or a parent.
Currently previewing #3b82f6.--txt-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 40px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.