Words fly out of the distance, hold for a beat, then rush past the camera as the next one arrives. Each word travels along the Z axis inside a perspective box, staggered by a delay.
Also known as: text flying at camera, 3d zoom text animation, warp speed words.
<div class="txt-zoom-through-text" aria-label="Faster, higher, stronger"><span class="txt-zoom-through-text-words" aria-hidden="true"><span style="--i: 0">FASTER</span><span style="--i: 1">HIGHER</span><span style="--i: 2">STRONGER</span></span></div>
.txt-zoom-through-text {
--c: var(--txt-color, #3b82f6);
font-size: calc(var(--txt-size, 32px) * 1.3);
font-family: system-ui, sans-serif;
font-weight: 900;
line-height: 1.2;
display: inline-block;
perspective: 6em;
color: var(--c);
letter-spacing: 0.04em;}
.txt-zoom-through-text-words {
display: grid;
place-items: center;
transform-style: preserve-3d;
}
.txt-zoom-through-text-words span {
grid-area: 1 / 1;
opacity: 0;
animation: txt-zoom-through-text-fly 4.2s infinite backwards;
animation-delay: calc(var(--i) * 1.4s - 0.4s); /* the first word is already on its way */
}
/* arrive fast and slow down, drift while readable, then accelerate past.
No filter here: a filtered layer drops out of 3D depth sorting. */
@keyframes txt-zoom-through-text-fly {
0% { opacity: 0; transform: translateZ(-14em); animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1); }
12% { opacity: 1; transform: translateZ(-0.6em); animation-timing-function: linear; }
30% { opacity: 1; transform: translateZ(0.4em); animation-timing-function: cubic-bezier(0.6, 0, 1, 0.6); }
40%, 100% { opacity: 0; transform: translateZ(4.2em); }
}
@media (prefers-reduced-motion: reduce) {
.txt-zoom-through-text, .txt-zoom-through-text *, .txt-zoom-through-text::before, .txt-zoom-through-text::after, .txt-zoom-through-text *::before, .txt-zoom-through-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.