Grid-row And Grid-column
Grid-row-start and grid-column-start ..
The
grid-row-start
&grid-row-end
CSS property specifies a grid item’s start position & end position within the grid row by contributing a line, a span, or nothing (automatic) to its grid placement, thereby specifying inline-start edge and inline-end edge of its grid area.The
grid-column-start
&grid-column-end
CSS property specifies a grid item’s start position and end position within the grid column by contributing a line, a span, or nothing (automatic) to its grid placement. These defines the block-start edge and block-end edge of the grid area.
Example
Determines a grid item’s location within the grid by referring to specific grid lines. grid-column-start/grid-row-start is the line where the item begins, and grid-column-end/grid-row-end is the line where the item ends.
Values:
<line>
– can be a number to refer to a numbered grid line, or a name to refer to a named grid linespan <number>
– the item will span across the provided number of grid tracksspan <name>
– the item will span across until it hits the next line with the provided nameauto
– indicates auto-placement, an automatic span, or a default span of one
e.g.
1 | .item-a { |
1 | .item-b { |
If no grid-column-end/grid-row-end is declared, the item will span 1 track by default.
Items can overlap each other. You can use z-index to control their stacking order.
Syntax
1 | /* Keyword value */ |
Grid-row and grid-column
Typing both
grid-column-start
andgrid-column-end
every time can get tiring. Fortunately,grid-column
is a shorthand property that can accept both values at once, separated by a slash.
For example, grid-column: 2 / 4; will set the grid item to start on the 2nd vertical grid line and end on the 4th grid line.The grid-row and grid-column properties define which row or column an element will be displayed on. Grid-row is shorthand for
grid-row-start
+grid-row-end
, grid-column is shorthand forgrid-column-start
+grid-column-end
.
1 | #water { |
Example
Here’s an explicit 3 × 3 grid where these properties are used to place grid items onto it in specific places:
Values:
<start-line> / <end-line>
– each one accepts all the same values as the longhand version, including span
e.g.
1 | .item-c { |
If no end line value is declared, the item will span 1 track by default.