🎨
Card Hover Effects 🎴
Intermediate
140 XP
50 min
Lesson Content
Card Hover Effects 🎴
Add smooth hover effects to cards that make your design feel interactive and modern.
Hover Transform
.card {
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card:hover {
transform: translateY(-10px) scale(1.02);
box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}Overlay Effect
.card::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
opacity: 0;
transition: opacity 0.3s;
}
.card:hover::before {
opacity: 1;
}Example Code
Create a card with hover effect
<div class="card">
<h3>Card Title</h3>
<p>Card content</p>
</div>
<style>
.card {
width: 300px;
padding: 30px;
background: white;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
transition: all 0.3s;
}
.card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}
</style>Expected Output:
Card that lifts on hover
Study Tips
- •Read the theory content thoroughly before practicing
- •Review the example code to understand key concepts
- •Proceed to the Practice tab when you're ready to code