Three words drop in from above and stack up, bottom first. Each lands with a squash, and the words underneath dip under the weight, using the separate translate and scale properties.
Also known as: falling words animation, words drop and stack, stacked headline animation.
<div class="txt-stacking-words-drop"> <span>Design.</span> <span>Build.</span> <span>Launch.</span> </div>
.txt-stacking-words-drop {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
line-height: 1.05;
text-align: center;
color: var(--c);}
.txt-stacking-words-drop span {
display: block;
transform-origin: 50% 100%;
}
/* bottom word lands first, then one every 0.3s; landing is 45% into the drop */
.txt-stacking-words-drop span:nth-child(3) {
animation: txt-stacking-words-drop-fall 0.7s both, txt-stacking-words-drop-dip 0.3s ease-out 0.615s 2;
}
.txt-stacking-words-drop span:nth-child(2) {
animation: txt-stacking-words-drop-fall 0.7s 0.3s both, txt-stacking-words-drop-dip 0.3s ease-out 0.915s;
}
.txt-stacking-words-drop span:nth-child(1) {
animation: txt-stacking-words-drop-fall 0.7s 0.6s both;
}
@keyframes txt-stacking-words-drop-fall {
0% { opacity: 0; transform: translateY(-1.3em) scale(0.94, 1.1); animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
15% { opacity: 1; }
45% { transform: translateY(0) scale(1.12, 0.8); animation-timing-function: cubic-bezier(0, 0.55, 0.45, 1); }
65% { transform: translateY(-0.12em) scale(0.97, 1.04); animation-timing-function: ease-in-out; }
82% { transform: translateY(0) scale(1.02, 0.98); }
100% { opacity: 1; transform: translateY(0) scale(1, 1); }
}
/* the words underneath give a little when a new one lands */
@keyframes txt-stacking-words-drop-dip {
0%, 100% { translate: 0 0; scale: 1 1; }
25% { translate: 0 0.06em; scale: 1.03 0.94; }
}
@media (prefers-reduced-motion: reduce) {
.txt-stacking-words-drop, .txt-stacking-words-drop *, .txt-stacking-words-drop::before, .txt-stacking-words-drop::after, .txt-stacking-words-drop *::before, .txt-stacking-words-drop *::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.