Is it possible to make a range of grid elements from the first to the last row, when I do not know the number of rows?
This feature seems to be missing from CSS Grid Module Level 1 . So the answer will be no, this is currently not possible.
While the CSS Grid cannot make the grid area span all columns / rows in the implicit grid, it can do the job in the explicit grid.
Use negative integers.
Here are two interesting sections in the CSS Grid specification:
7.1. Explicit grid
Numeric indices in grid placement properties are calculated at the edges of the explicit grid. Positive indices are counted from the beginning, while negative indices are counted from the end.
and here...
8.3. grid-row-start based layout: grid-row-start , grid-column-start , grid-row-end and grid-column-end properties
If a negative integer is specified, it is instead counted in reverse order, starting from the extreme edge of the explicit grid.
In other words, when working with an explicit grid, which is the grid that you define using these properties:
grid-template-rowsgrid-template-columnsgrid-template-areas
... you can make the grid area cover all columns by setting this rule:
grid-column: 3 / -1;
This indicates that the grid area will span from the third row of the column to the last row of the column.
The converse will be:
grid-column: 1 / -3;
Again, this method only works on explicit grids.
source share