1
2
3
4
5
6
grid-template-columns
with the new unit by adding
fr
to our columns.fr
unit divide the space in fractional unit, for example
here our container is divide in 3 columns, so 1fr
will take 1 part of the available space.fr
unit work also with grid-template-rows
.7
8
9
10
11
12
grid-template-rows
and
grid-template-columns
simply add a columns or a row by adding a new parameter with a unit
like this, grid-template-columns: 1fr 1fr 1fr
, but there is a better way to do that.repeat()
function who can help to avoid DRY.repeat()
function need two parameters, the first parameter
will be the number of columns you need, the second parameter is the size of yours columns.grid-template-columns: repeat(3,1fr)
.grid-template-rows
.13
14
15
16
17
18
grid-template-columns
and grid-template-rows
but there is a better solution.grid-template
method is a shorthand for grid-template-columns
and grid-template-rows
the first instructions define row and the second define columns.grid-template: repeat(2,50px) / repeat(3,1fr)
.repeat()
function.