css - Button Hover Animations
CSS Button Hover Animations are used to create interactive visual effects on buttons when the mouse pointer moves over them. These animations improve user experience and make websites look modern and professional.
1. What are Button Hover Animations?
Button Hover Animations change the style, color, size, or effect of a button on hover using only CSS.
They are commonly used in:
- Login forms
- Submit buttons
- Call-to-action (CTA) buttons
2. Basic Button Structure
HTML:
<button class="btn">Hover Me</button>
CSS:
.btn {
padding: 12px 25px;
background: #4caf50;
color: white;
border: none;
cursor: pointer;
transition: 0.4s;
}
3. Simple Hover Animation (Color Change + Scale)
.btn:hover {
background: black;
transform: scale(1.1);
}
Button changes color and slightly zooms on hover.
4. Glow Hover Effect
.btn:hover {
box-shadow: 0 0 15px #4caf50;
}
Creates a glowing light effect around the button.
5. Slide Hover Effect (Using ::before)
.btn {
position: relative;
overflow: hidden;
}
.btn::before {
content: "";
position: absolute;
background: black;
width: 100%;
height: 100%;
top: 0;
left: -100%;
transition: 0.4s;
}
.btn:hover::before {
left: 0;
}
Creates a sliding background effect on hover.
6. Advantages
- Makes buttons attractive
- Improves user interaction
- Easy to design
- No JavaScript required
- Used in all modern websites
Conclusion
CSS Button Hover Animations help create interactive and eye-catching buttons using simple properties like hover, transition, transform, and box-shadow.