12. Grid: rows and columns
Este artículo se traducirá automáticamente. Por ahora se muestra en inglés.
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.
Ver ejemplo
.gallery {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
✍️ Ahora te toca
Make .gallery a grid with four equal columns and a gap of 8px.