Flips into view around its horizontal axis in perspective, overshoots past flat and wobbles to rest. The perspective() sits inside the transform, so no wrapper is needed.
Also known as: flip in x css, flip in horizontal axis, 3d flip down animation.
<div class="kfa-flip-in-x">Flip X</div>
.kfa-flip-in-x {
--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);
animation: kfa-flip-in-x-kf 0.9s ease-in both;
}
@keyframes kfa-flip-in-x-kf {
0% { opacity: 0; transform: perspective(25em) rotateX(85deg); }
40% { transform: perspective(25em) rotateX(-18deg); }
60% { opacity: 1; transform: perspective(25em) rotateX(9deg); }
80% { transform: perspective(25em) rotateX(-4deg); }
100% { opacity: 1; transform: perspective(25em) rotateX(0); }
}
@media (prefers-reduced-motion: reduce) {
.kfa-flip-in-x, .kfa-flip-in-x *, .kfa-flip-in-x::before, .kfa-flip-in-x::after, .kfa-flip-in-x *::before, .kfa-flip-in-x *::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.