AI CSS Animations

Zoom In

Grows from 30 percent while fading in over the first half, then eases out to full size. The standard modal and lightbox entrance, and it works on any element.

Also known as: zoom in animation css, scale in animation css, zoom in effect.

Zoom

HTML

<div class="kfa-zoom-in">Zoom</div>

CSS

.kfa-zoom-in {
  --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-zoom-in-kf 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes kfa-zoom-in-kf {
  0% { opacity: 0; transform: scale(0.3); }
  50% { opacity: 1; }
  100% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .kfa-zoom-in, .kfa-zoom-in *, .kfa-zoom-in::before, .kfa-zoom-in::after, .kfa-zoom-in *::before, .kfa-zoom-in *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --kfa-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --kfa-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar keyframe animations