Here is the complete story, code breakdown, and implementation for creating a responsive product card.
For a responsive card, the image is usually the tricky part. We want to ensure it doesn't distort.
.product-image
position: relative;
height: 250px;
overflow: hidden;
.product-image img
width: 100%;
height: 100%;
object-fit: cover; /* Crops image nicely to fill the container */
transition: transform 0.5s ease;
/* Zoom effect on hover */
.product-card:hover .product-image img
transform: scale(1.05);
We use semantic tags. article acts as the card container, figure handles the image, and section groups the text. responsive product card html css codepen
<div class="product-container"> <article class="product-card"> <!-- The Image Area --> <figure class="product-image"> <img src="https://images.unsplash.com/photo-1548036328-c9fa89d128fa?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80" alt="Vintage Leather Bag on wooden table"> <span class="product-badge">New</span> </figure><!-- The Content Area --> <section class="product-details"> <header> <h3 class="product-title">The Wanderer Rucksack</h3> <p class="product-subtitle">Handcrafted Vintage Leather</p> </header> <p class="product-description"> A durable and stylish companion for your weekend trips. Made with full-grain leather that ages beautifully over time. </p> <footer class="product-footer"> <div class="product-price"> <span class="price-current">$189.00</span> <span class="price-original">$230.00</span> </div> <button class="add-to-cart">Add to Cart</button> </footer> </section>
</article> </div>
You can copy and paste this directly into the HTML and CSS panels on CodePen.
<div class="products-grid">
<div class="product-card">
<img src="https://via.placeholder.com/300x200" alt="Product">
<h3>Classic White Sneakers</h3>
<p class="price">$49.99</p>
<button>Add to Cart</button>
</div>
<!-- Repeat cards -->
</div>
If you are building an e-commerce site, a portfolio, or just practicing your layout skills, the product card is the bread and butter of web design. It’s where design meets functionality. A bad card layout can ruin a shopping experience, while a smooth, responsive one can drive conversions. Here is the complete story, code breakdown, and
Today, we are going to build a modern, responsive product card using only HTML and CSS. No JavaScript required for the layout!
Here is what we are aiming for: a card that looks great on mobile, adapts to larger screens, and includes hover effects to make it feel interactive. The Image Area For a responsive card, the