The word is slowly pulled wide and flat, then let go: it snaps back past its shape, wobbles tall and wide a few times and settles. A long rest after each snap keeps it from nagging.
Also known as: rubber band animation css, elastic stretch text, rubberband text.
<div class="txt-rubber-band-text">Snap back</div>
.txt-rubber-band-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;
color: var(--c);
animation: txt-rubber-band-text-snap 2.8s infinite;}
@keyframes txt-rubber-band-text-snap {
0%, 6%, 54%, 100% { transform: scale(1, 1); animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
/* slow pull, building tension */
26% { transform: scale(1.3, 0.8); animation-timing-function: cubic-bezier(0.2, 0, 0.3, 1); }
/* release: overshoot and ring down */
31% { transform: scale(0.82, 1.16); animation-timing-function: ease-in-out; }
37% { transform: scale(1.1, 0.92); animation-timing-function: ease-in-out; }
43% { transform: scale(0.96, 1.04); animation-timing-function: ease-in-out; }
49% { transform: scale(1.02, 0.99); animation-timing-function: ease-in-out; }
}
@media (prefers-reduced-motion: reduce) {
.txt-rubber-band-text, .txt-rubber-band-text *, .txt-rubber-band-text::before, .txt-rubber-band-text::after, .txt-rubber-band-text *::before, .txt-rubber-band-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.