AI CSS Animations

Jump

A cartoon jump every two seconds: it crouches, stretches tall on take off, squashes on landing and waits. Anticipation and a rest make it feel alive, not frantic. The pivot is the bottom edge.

Also known as: css jump animation, squash and stretch, jumping loop.

Jump

HTML

<div class="kfa-jump">Jump</div>

CSS

.kfa-jump {
  --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: 50% 100%;
  animation: kfa-jump-leap 2s infinite;
}
@keyframes kfa-jump-leap {
  0% { transform: translateY(0) scale(1, 1); animation-timing-function: ease-in-out; }
  /* crouch and hold */
  9%, 13% { transform: translateY(0) scale(1.14, 0.84); animation-timing-function: cubic-bezier(0.3, 0, 0.5, 1); }
  /* take off stretched, slow into the top */
  19% { transform: translateY(-0.8em) scale(0.88, 1.16); animation-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1); }
  31% { transform: translateY(-1.9em) scale(1, 1); animation-timing-function: cubic-bezier(0.55, 0, 0.8, 0.4); }
  /* fall, squash, settle */
  41% { transform: translateY(0) scale(0.92, 1.1); animation-timing-function: ease-out; }
  45% { transform: translateY(0) scale(1.18, 0.82); animation-timing-function: ease-in-out; }
  51% { transform: translateY(0) scale(0.96, 1.04); animation-timing-function: ease-in-out; }
  57%, 100% { transform: translateY(0) scale(1, 1); }
}

@media (prefers-reduced-motion: reduce) {
  .kfa-jump, .kfa-jump *, .kfa-jump::before, .kfa-jump::after, .kfa-jump *::before, .kfa-jump *::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