The word snaps out from its left edge like a tape measure, overstretches, and wobbles back to size. Width and height trade off at each keyframe so the text keeps its volume.
Also known as: rubber band text entrance, stretch in text css, spring text animation.
<div class="txt-elastic-stretch-text">Snap back</div>
.txt-elastic-stretch-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: inline-block;
white-space: nowrap;
color: var(--c);
transform-origin: 0 50%;
animation: txt-elastic-stretch-text-snap 1.1s both;}
@keyframes txt-elastic-stretch-text-snap {
0% { opacity: 0; transform: scale(0.1, 1.3); animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1); }
10% { opacity: 1; }
30% { transform: scale(1.3, 0.82); animation-timing-function: ease-in-out; }
47% { transform: scale(0.88, 1.1); animation-timing-function: ease-in-out; }
63% { transform: scale(1.07, 0.95); animation-timing-function: ease-in-out; }
78% { transform: scale(0.97, 1.02); animation-timing-function: ease-in-out; }
90% { transform: scale(1.01, 1); }
100% { opacity: 1; transform: scale(1, 1); }
}
@media (prefers-reduced-motion: reduce) {
.txt-elastic-stretch-text, .txt-elastic-stretch-text *, .txt-elastic-stretch-text::before, .txt-elastic-stretch-text::after, .txt-elastic-stretch-text *::before, .txt-elastic-stretch-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.