A CLOSED sign loses its right nail, drops, and swings on the left one before settling at a crooked tilt. A damped rotation around the remaining nail that plays once and stays put.
Also known as: hinge animation css, falling sign text, broken sign effect.
<div class="txt-hinge-drop-text"><span class="txt-hinge-drop-text-sign">CLOSED</span></div>
.txt-hinge-drop-text {
--c: var(--txt-color, #3b82f6);
font-size: calc(var(--txt-size, 32px) * 1.2);
font-family: system-ui, sans-serif;
font-weight: 800;
line-height: 1.2;
display: inline-block;
padding-bottom: 1.4em; /* room for the drop */}
.txt-hinge-drop-text-sign {
position: relative;
display: inline-block;
padding: 0.3em 0.7em;
border: 0.07em solid var(--c);
border-radius: 0.12em;
color: var(--c);
letter-spacing: 0.12em;
background: color-mix(in srgb, var(--c) 10%, transparent);
transform-origin: 0.3em 0.3em; /* the nail that holds */
animation: txt-hinge-drop-text-swing 2.4s both;
}
/* the two nails: the left one holds, the right one pops out */
.txt-hinge-drop-text-sign::before,
.txt-hinge-drop-text-sign::after {
content: "";
position: absolute;
top: 0.22em;
width: 0.16em;
height: 0.16em;
border-radius: 50%;
background: var(--c);
}
.txt-hinge-drop-text-sign::before {
left: 0.22em;
}
.txt-hinge-drop-text-sign::after {
right: 0.22em;
animation: txt-hinge-drop-text-nail 2.4s both;
}
@keyframes txt-hinge-drop-text-swing {
0%, 20% { transform: rotate(0deg); }
23% { transform: rotate(-1.5deg); animation-timing-function: cubic-bezier(0.5, 0, 0.9, 0.5); }
38% { transform: rotate(21deg); animation-timing-function: cubic-bezier(0.3, 0, 0.5, 1); }
52% { transform: rotate(7deg); animation-timing-function: cubic-bezier(0.5, 0, 0.5, 1); }
64% { transform: rotate(16deg); animation-timing-function: cubic-bezier(0.5, 0, 0.5, 1); }
75% { transform: rotate(10.5deg); animation-timing-function: cubic-bezier(0.5, 0, 0.5, 1); }
85% { transform: rotate(13.5deg); animation-timing-function: cubic-bezier(0.5, 0, 0.5, 1); }
100% { transform: rotate(12deg); }
}
@keyframes txt-hinge-drop-text-nail {
0%, 22% { opacity: 1; transform: none; }
40% { opacity: 0; transform: translate(0.3em, 1.2em) rotate(120deg); }
100% { opacity: 0; transform: translate(0.3em, 1.2em) rotate(120deg); }
}
@media (prefers-reduced-motion: reduce) {
.txt-hinge-drop-text, .txt-hinge-drop-text *, .txt-hinge-drop-text::before, .txt-hinge-drop-text::after, .txt-hinge-drop-text *::before, .txt-hinge-drop-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.