A word balances on a plank that tips from side to side, sliding toward whichever end is low. The slide runs a beat behind the tilt, which is what makes the word feel like it has weight.
Also known as: tilting text, balance text animation, rocking text css.
<div class="txt-seesaw-text"><span class="txt-seesaw-text-plank"><span class="txt-seesaw-text-word">Balance</span></span></div>
.txt-seesaw-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;
position: relative;
display: inline-block;
padding-bottom: 0.45em;
color: var(--c);}
/* the fulcrum */
.txt-seesaw-text::after {
content: "";
position: absolute;
left: 50%;
bottom: 0;
width: 0.6em;
height: 0.45em;
margin-left: -0.3em;
background: color-mix(in srgb, var(--c) 45%, transparent);
clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.txt-seesaw-text-plank {
display: block;
padding: 0 0.7em 0.04em;
border-bottom: 0.08em solid color-mix(in srgb, var(--c) 70%, transparent);
border-radius: 0.05em;
transform-origin: 50% 100%;
animation: txt-seesaw-text-tilt 3.2s ease-in-out infinite;
}
.txt-seesaw-text-word {
display: inline-block;
animation: txt-seesaw-text-slide 3.2s ease-in-out infinite;
/* 0.4s behind the plank */
animation-delay: -2.8s;
}
@keyframes txt-seesaw-text-tilt {
0%, 100% { transform: rotate(-6deg); }
50% { transform: rotate(6deg); }
}
@keyframes txt-seesaw-text-slide {
0%, 100% { transform: translateX(-0.55em); }
50% { transform: translateX(0.55em); }
}
@media (prefers-reduced-motion: reduce) {
.txt-seesaw-text, .txt-seesaw-text *, .txt-seesaw-text::before, .txt-seesaw-text::after, .txt-seesaw-text *::before, .txt-seesaw-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.