Grid Container

What is CSS Grid?

CSS Grid lays out items in rows and columns at the same time. Flexbox is best for one row or column; Grid is best for whole page layouts and galleries.

.container {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;  /* three columns */
  grid-template-rows: auto 100px;
  gap: 10px;
}

The fr unit means "a fraction of the free space".

Example

Example

<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
  <style>
    .container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .container > div { background: #04AA6D; color: white; padding: 10px 16px; font: 15px Arial; }
    .container > div { text-align: center; }
  </style>
</head>
<body>

<div class="container">
  <div>1</div><div>2</div><div>3</div>
  <div>4</div><div>5</div><div>6</div>
</div>

</body>
</html>

Result