I have this code from a code snippet for CSS grid and found it really confusing.
grid-template-columns: [outer-start] 1fr [center-start] 1fr [center-end] 1fr [outer-end];
My doubt is, here will there be 3 columns or 4 columns?
I have this code from a code snippet for CSS grid and found it really confusing.
grid-template-columns: [outer-start] 1fr [center-start] 1fr [center-end] 1fr [outer-end];
My doubt is, here will there be 3 columns or 4 columns?
There will be 3 columns and 4 column-grid-lines. In terms of explicit column numbers and sizing
grid-template-columns: [outer-start] 1fr [center-start] 1fr [center-end] 1fr [outer-end];
is equivalent to
grid-template-columns: 1fr 1fr 1fr;
The thigs inside [
and ]
are gird line names. I suggest you to read this MDN article for an exhaustive explanation. These grid line names then later can be used to position grid-items, e.g.
.grid-item1 {
grid-column-start: center-start;
grid-column-end: outer-end;
}