CSS grid-template-rows Property
Example
Specify the row-size (height):
.grid-container {
display: grid;
grid-template-rows:
100px 300px;
}
Try it Yourself »
Definition and Usage
The grid-template-rows
property specifies the number
(and the heights) of the rows in a grid layout.
The values are a space-separated list, where each value specifies the height of the respective row.
Default value: | none |
---|---|
Inherited: | no |
Animatable: | yes. Read about animatable Try it |
Version: | CSS Grid Layout Module Level 1 |
JavaScript syntax: | object.style.gridTemplateRows="50px 200px" Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
grid-template-rows | 57 | 16 | 52 | 10 | 44 |
CSS Syntax
grid-template-rows: none|auto|max-content|min-content|minmax()|length|percentage|fit-content()|repeat()|subgrid|initial|inherit;
Property Values
Value | Description | Demo |
---|---|---|
none | No size is set. Rows are created if needed | Demo ❯ |
auto | The size of the rows is determined by the size of the container, and on the size of the content of the items in the row | Demo ❯ |
fit-content() | Sets the size of the rows in length or %, and works like the row will use the available space, but it will never expand the max-content size | |
max-content | Sets the size of each row to depend on the largest item in the row | |
min-content | Sets the size of each row to depend on the smallest item in the row | |
minmax() | Sets a size range greater than or equal to min and less than or equal to max | |
length | Sets the size of the rows, by using a legal length value. Read about length units | Demo ❯ |
percentage | Sets the size of the rows, in percent, relative to the inline size of the container | |
repeat() | Represents a repeated fragment of the track list | |
subgrid | Indicates that the grid will adopt the spanned portion of its parent grid in that axis | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit | |
Related Pages
CSS Tutorial: CSS Grid Layout
CSS Reference: The grid-columns property
CSS Reference: The grid-template property