Starlit Daily

📚 › CSS: style and layout

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.

عرض المثال

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

✍️ دورك الآن

Make .gallery a grid with four equal columns and a gap of 8px.

← العودة إلى الدورة