Drops out of its own top edge like a dropdown panel, overshoots a touch and settles. The clip-path inset follows every keyframe so nothing shows above the fold line.
Also known as: css slide down animation, slide in from top css, dropdown slide down.
<div class="kfa-slide-in-down">Slide</div>
.kfa-slide-in-down {
--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-slide-in-down-kf 0.75s both;
}
@keyframes kfa-slide-in-down-kf {
0% {
transform: translateY(-100%);
clip-path: inset(100% -1em 0 -1em);
animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1);
}
70% {
transform: translateY(0.35em);
clip-path: inset(-0.35em -1em -2em -1em);
animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
}
100% {
transform: translateY(0);
clip-path: inset(0 -1em -2em -1em);
}
}
@media (prefers-reduced-motion: reduce) {
.kfa-slide-in-down, .kfa-slide-in-down *, .kfa-slide-in-down::before, .kfa-slide-in-down::after, .kfa-slide-in-down *::before, .kfa-slide-in-down *::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.