Letters take turns jumping with cartoon squash and stretch: a crouch, a tall stretch on the way up, a flat squash on landing. The pivot sits on the baseline, so they squash into the floor.
Also known as: bouncing letters css, jumping letters, squash and stretch text.
<div class="txt-bouncing-text" aria-label="Let's play!"><span aria-hidden="true"><span style="--i: 0">L</span><span style="--i: 1">e</span><span style="--i: 2">t</span><span style="--i: 3">'</span><span style="--i: 4">s</span><span style="--i: 5"> </span><span style="--i: 6">p</span><span style="--i: 7">l</span><span style="--i: 8">a</span><span style="--i: 9">y</span><span style="--i: 10">!</span></span></div>
.txt-bouncing-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;
color: var(--c);}
.txt-bouncing-text span span {
display: inline-block;
transform-origin: 50% 100%;
animation: txt-bouncing-text-hop 2.2s infinite;
animation-delay: calc(var(--i) * 0.08s);
}
@keyframes txt-bouncing-text-hop {
0%, 42%, 100% { transform: translateY(0) scale(1, 1); animation-timing-function: ease-out; }
/* crouch, launch, rise */
5% { transform: translateY(0) scale(1.18, 0.82); animation-timing-function: ease-in; }
9% { transform: translateY(-0.1em) scale(0.88, 1.16); animation-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1); }
20% { transform: translateY(-0.62em) scale(1, 1); animation-timing-function: cubic-bezier(0.55, 0, 0.8, 0.4); }
/* fall, squash, settle */
29% { transform: translateY(0) scale(0.9, 1.12); animation-timing-function: ease-out; }
33% { transform: translateY(0) scale(1.22, 0.78); animation-timing-function: ease-in-out; }
38% { transform: translateY(0) scale(0.96, 1.04); animation-timing-function: ease-in-out; }
}
@media (prefers-reduced-motion: reduce) {
.txt-bouncing-text, .txt-bouncing-text *, .txt-bouncing-text::before, .txt-bouncing-text::after, .txt-bouncing-text *::before, .txt-bouncing-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.