Loading lessons...
Project 7: Animated Buttons
Project 7: Animated Buttons
Buttons that react: hovers, transitions and a bouncing keyframe.
The three moves
.btn {
transition: transform 0.2s ease, background 0.2s ease;
}
.btn:hover {
transform: translateY(-2px);
background: #46a302;
}
.btn.is-busy {
animation: bob 0.8s infinite;
}
@keyframes bob {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-6px); }
}
Understand it
transitionsmoothly eases property jumps when the state changes.:hoveris the trigger - transitions run on change.@keyframesdefines reusable motion stages;animationattaches them.infiniterepeats the loop forever; addease-in-outfor polish.
Your mission
- One button that grows or lifts on hover.
- One that changes color with a transition.
- One that loops a keyframe animation when it has a class.
- Respect
prefers-reduced-motion? Pro:@media (prefers-reduced-motion: reduce)- turn it off.
Checklist
- [ ] Transition on at least one button
- [ ] A
:hoverstate - [ ] One @keyframes animation running with infinite
- [ ] Reduced-motion media query handling
TL;DR
transition = smooth property change; @keyframes = reusable loops; hover triggers the show.