ALL DEMOS

Bouncing
ball ×4

A classic bouncing ball animation. It looks simple, but it's hard to make it look real. The physics changes the ball in small ways. Each version has the same phases: launch, apex, then three decaying bounces, with the ball squashing on every impact and the shadow shrinking as it rises.

010 kB · NATIVECSS9 keyframes · per-frame cubic-bezier
0227 kB gz · 3.13GSAP9 tweens · power2 in / out
033 kB gz · v11Motion10-value array · times[] · ease[]
0412 kB gz · v4Anime.js8 segments · outQuad / inQuad

0.00 / 2.00 S

0 · LAUNCH
APEX
IMPACT
40%
14%
BALL HEIGHT KEYFRAMES
bounce.css
@keyframes ball-y {
  0%   { transform: translateY(0);
         animation-timing-function: cubic-bezier(.16,.62,.34,1) }
  26%  { transform: translateY(-150px);
         animation-timing-function: cubic-bezier(.66,.02,.84,.4) }
  48%  { transform: translateY(0);
         animation-timing-function: cubic-bezier(.16,.62,.34,1) }
  62%  { transform: translateY(-60px) }
  /* …74% 82% 88% 92% 95% 100% */
}

/* Squash lands on contact: the two steps into a squash
   ease in, every other step takes the rule's ease-out. */
@keyframes ball-squash {
  0%     { transform: scale(1.25, 0.75); }
  6%     { transform: scale(1, 1); }
  30%    { transform: scale(0.95, 1.05); }
  46%    { transform: scale(1, 1); animation-timing-function: ease-in; }
  48%    { transform: scale(1.2, 0.8); }
  54%    { transform: scale(1, 1); }
  69%    { transform: scale(0.95, 1.05); animation-timing-function: ease-in; }
  74%    { transform: scale(1.15, 0.85); }
  80%,
  100%   { transform: scale(1, 1); }
}

/* Smaller and fainter the higher the ball is. */
@keyframes ball-shadow {
  0%, 48%, 74%, 88%, 100% { transform: scale(1);    opacity: .45 }
  26%                     { transform: scale(.45);  opacity: .12 }
  62%                     { transform: scale(.72);  opacity: .25 }
  82%                     { transform: scale(.88);  opacity: .35 }
}

.ball   { animation: ball-y      2s linear   infinite }
.squash { animation: ball-squash 2s ease-out infinite }
.shadow { animation: ball-shadow 2s linear   infinite }

Ratings

OnboardingHow fast I got a first version working.
ErgonomicsHow well the API fits the job once you know it.
IterationHow cheap it is to tweak a number and look again.
DebuggingHow easy it was to find out why it looked wrong.
RealismHow close the result is to the motion in the brief.

What I like

Nothing to install, and it only animates transform and opacity, so the browser can run it on its own thread and keep it smooth while JavaScript is busy.

What I don't

Each keyframe's timing is a percentage of a total I work out by hand, so changing the duration means redoing all of them. And transform is one property, so I had to nest two elements to move and squash the ball separately.

How it's built

9 keyframes · per-frame cubic-bezier

Loading engines…