Jul 30, 2025
This lecture covers the CSS grid-template-rows property, which defines how rows are sized and named in a CSS Grid layout.
grid-template-rows sets the line names and track sizing for the grid rows.display: grid or display: inline-grid.grid-template-rows: <track-list> | <auto-track-list> | subgrid | none;auto, 40px 4em 40px, 1fr 2fr 1fr, repeat(3, 200px).grid-template-rows: 30px 1fr; creates two rows, one 30px and the other filling remaining space.none: No explicit grid; rows are created implicitly.<length>: Sets row height in px, em, etc.<percentage>: Relative to grid container’s block size.<flex> (fr): Distributes remaining space proportionally.min-content/max-content: Adapts to minimum/maximum content size.minmax(min,max): Defines a size range for a row.auto: Row adapts between minimum and maximum item size.fit-content(<length>|<percentage>): Clamped size based on content, but limited by argument.repeat(count, value): Repeats a track definition; auto-fill/auto-fit adjust number of rows automatically.subgrid: Adopts row sizing from the parent grid.masonry: Uses masonry algorithm for row layout.none.#grid {
display: grid;
height: 100px;
grid-template-rows: 30px 1fr;
}
display: grid or inline-grid, hosting grid items.grid-template-rows with various value types.minmax().repeat(), subgrid, and auto values to see their effects on grid layouts.