12. Grid: rows and columns
display: grid makes a two-dimensional layout. grid-template-columns sets the columns; repeat(3, 1fr) makes three equal columns. The gap property spaces the cells.
Use grid for page layouts and galleries, and flexbox for rows of items.
Show example
.gallery {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
✍️ Your turn
Make .gallery a grid with four equal columns and a gap of 8px.