📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials CSS Mastery CSS Grid Advanced

CSS Grid Advanced

6 min read Quiz at the end
repeat(auto-fill, minmax(250px, 1fr)) creates a responsive grid that adjusts columns to fit. grid-auto-flow: dense fills gaps from spanning items. This eliminates the need for breakpoint-based column media queries.

Advanced Grid Techniques

/* Auto-fill responsive grid (no media queries!) */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
}

/* Span multiple columns */
.featured {
    grid-column: span 2;
    grid-row: span 2;
}

/* Subgrid */
.card-grid {
    grid-template-rows: subgrid;
}
Topic Quiz · 5 questions

Test your understanding before moving on

1. What does minmax(200px, 1fr) do?
💡 minmax() defines a min and max size for a grid track.
2. auto-fill in grid:
💡 auto-fill fills the row with as many columns as possible, keeping empty columns.
3. grid-column: span 2 means:
💡 span 2 makes the item span 2 column tracks.
4. What is subgrid?
💡 subgrid allows children to align to the parent grid's tracks rather than creating a new grid.
5. dense keyword in grid-auto-flow:
💡 grid-auto-flow: dense fills gaps by moving smaller items back to fill holes.