Pivots down into place around its bottom left corner, like a door swinging shut, and overshoots by a few degrees. Moving transform-origin to a corner is the whole trick.
Also known as: rotate in from corner css, rotate in down left animation, door swing in.
<div class="kfa-rotate-in-down-left">Pivot</div>
.kfa-rotate-in-down-left {
--c: var(--kfa-color, #3b82f6);
font-size: var(--kfa-size, 16px);
display: grid;
place-items: center;
width: 5.5em;
height: 5.5em;
border-radius: 1em;
background: var(--c);
color: #fff;
font-family: system-ui, sans-serif;
font-weight: 700;
box-shadow: 0 0.6em 1.4em -0.6em color-mix(in srgb, var(--c) 70%, transparent);
transform-origin: 0 100%;
animation: kfa-rotate-in-down-left-kf 0.8s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}
@keyframes kfa-rotate-in-down-left-kf {
0% { opacity: 0; transform: rotate(-45deg); }
40% { opacity: 1; }
100% { opacity: 1; transform: rotate(0); }
}
@media (prefers-reduced-motion: reduce) {
.kfa-rotate-in-down-left, .kfa-rotate-in-down-left *, .kfa-rotate-in-down-left::before, .kfa-rotate-in-down-left::after, .kfa-rotate-in-down-left *::before, .kfa-rotate-in-down-left *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--kfa-color on the element or a parent.
Currently previewing #3b82f6.--kfa-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.