Design reusable card components with images, text content, and interactive elements.
This project will guide you through creating flexible, reusable card components using HTML and CSS. You'll learn to structure cards, style them, and add interactive effects.
Beginner: 1-2 hours | Intermediate: 1 hour
Difficulty Level: Beginner
<div class="card">
<img src="image.jpg" alt="Card Image">
<div class="card-content">
<h3>Card Title</h3>
<p>Short description of the card content.</p>
<a href="#" class="card-action">Learn More</a>
</div>
</div>
.card {
background: white;
border-radius: 12px;
box-shadow: 0 4px 20px rgba(0,0,0,0.08);
overflow: hidden;
max-width: 350px;
margin: 1rem auto;
transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
transform: translateY(-8px) scale(1.03);
box-shadow: 0 12px 32px rgba(102,126,234,0.15);
}
.card img {
width: 100%;
height: 180px;
object-fit: cover;
}
.card-content {
padding: 1.5rem;
}
.card-content h3 {
margin: 0 0 0.5rem 0;
font-size: 1.3rem;
color: var(--primary, #667eea);
}
.card-content p {
color: #666;
margin-bottom: 1rem;
}
.card-action {
display: inline-block;
background: linear-gradient(90deg, #667eea, #764ba2);
color: white;
padding: 0.5rem 1.5rem;
border-radius: 6px;
text-decoration: none;
font-weight: 600;
transition: background 0.2s;
}
.card-action:hover {
background: #764ba2;
}
@media (max-width: 500px) {
.card {
max-width: 100%;
}
}
<div class="card-grid">
<div class="card">...</div>
<div class="card">...</div>
<div class="card">...</div>
</div>
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
margin: 2rem 0;
}