A rubbery button that wobbles like jelly when the cursor lands on it: stretched wide, then tall, settling in smaller swings. One scale keyframe runs once per hover.
Also known as: rubber band button, wobble button hover, jello button css.
<button class="btn-jelly">Boing</button>
.btn-jelly {
--c: var(--btn-color, #3b82f6);
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5em;
font: 600 var(--btn-size, 18px)/1.2 system-ui, sans-serif;
cursor: pointer;
padding: 0.8em 2em;
border: 0;
border-radius: 0.9em;
background: var(--c);
color: #fff;
transition: background-color 0.3s ease;}
.btn-jelly:is(:hover, :focus-visible) {
background-color: color-mix(in srgb, var(--c) 82%, #fff);
animation: btn-jelly-wobble 0.9s both;
}
@keyframes btn-jelly-wobble {
0%, 100% { transform: scale(1, 1); }
25% { transform: scale(1.22, 0.78); }
40% { transform: scale(0.8, 1.2); }
55% { transform: scale(1.12, 0.88); }
70% { transform: scale(0.95, 1.05); }
85% { transform: scale(1.03, 0.97); }
}
@media (prefers-reduced-motion: reduce) {
.btn-jelly, .btn-jelly *, .btn-jelly::before, .btn-jelly::after, .btn-jelly *::before, .btn-jelly *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--btn-color on the element or a parent.
Currently previewing #3b82f6.--btn-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 18px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.