Falls fast, touches down and rises slowly, over and over, like a ball tapping the floor. The same curve as Tailwind's animate-bounce: an ease-in drop and an ease-out climb.
Also known as: css bounce up and down, infinite bounce animation, tailwind animate bounce.
<div class="kfa-bounce-up-and-down">Bounce</div>
.kfa-bounce-up-and-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-bounce-up-and-down-hop 1s infinite;
}
@keyframes kfa-bounce-up-and-down-hop {
0%, 100% { transform: translateY(-1.4em); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
50% { transform: translateY(0); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}
@media (prefers-reduced-motion: reduce) {
.kfa-bounce-up-and-down, .kfa-bounce-up-and-down *, .kfa-bounce-up-and-down::before, .kfa-bounce-up-and-down::after, .kfa-bounce-up-and-down *::before, .kfa-bounce-up-and-down *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}The same effect using Tailwind utility classes. No custom CSS or config needed.
<div class="grid h-[5.5em] w-[5.5em] animate-bounce place-items-center rounded-[1em] bg-blue-500 font-bold text-white"> Bounce </div>
--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.