Course contentsShow
← Web Development
Lesson 374 of 2,9826. CSS GridFree lesson

Responsive Product Listings

Build e-commerce product grids with featured items that span multiple cells.

Responsive Product Listings

You'll learn how to create e-commerce product grids where certain featured items can span multiple grid cells, creating visual hierarchy.

When building online stores, you want some products to grab more attention—maybe a sale item, a new arrival, or a best-seller. CSS Grid lets you create dynamic product listings where featured items take up more space (spanning multiple rows or columns) while regular products fill single cells.

Think of it like a newspaper layout: regular articles get standard columns, but the headline story spans wider to draw your eye first.

Building the Pattern

Start with a responsive grid using auto-fit and minmax():

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

This creates a flexible grid that adapts to screen size. Now make certain products featured by spanning multiple cells:

.product {
  /* Regular product: takes 1 cell */
}

.product.featured {
  grid-column: span 2;
  grid-row: span 2;
}

.product.wide {
  grid-column: span 2;
}

The .featured item will occupy four cells (2 columns × 2 rows), creating a larger showcase area. The .wide item stretches horizontally across two columns, perfect for banner-style promotions.

The Result

Your grid automatically flows regular products around the featured ones. On mobile, when columns collapse to 1, the span 2 simply makes the item fill the full width—no media queries needed!

Key Takeaway: Use grid-column: span and grid-row: span on featured products to create visual hierarchy in responsive e-commerce grids, letting important items naturally take up more space while the grid handles the rest automatically.