Q23: What problem does CSS Subgrid solve in nested grid components?
grid-template-columns: subgrid or grid-template-rows: subgrid allows nested child grids to inherit track alignments defined on parent grids, enabling card headers, bodies, and footers across adjacent grid cards to align perfectly.
Subgrid Card Layout Alignment
.parent-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
.card {
display: grid;
grid-template-rows: subgrid;
grid-row: span 3;
}Subgrid forces card headers, bodies, and footers across neighboring cards to align along parent row lines.
Key Takeaways
Nested grid components share parent column and row track lines.
Aligns nested headers, bodies, and footers across adjacent cards.
Knowledge Check
What primary layout capability does subgrid provide?