CSS3 & Modern Layouts (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
CSS Subgrid: `grid-template-columns: subgrid`.
senior LevelCode ExampleComponentsSystem Design
In Simple Words: In standard CSS Grid, child grid elements define their own independent column/row sizing, making it difficult to align sibling card headers, descriptions, and footers across rows. Subgrid allows child grids to adopt and align directly with the parent grid's tracks.
css
.card-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1.5rem;
}
.card {
display: grid;
grid-template-rows: subgrid; /* Inherits parent rows */
grid-row: span 3; /* Header, Body, Footer align across all cards */
}