<div class="grid">
  <div></div>
  <div>I have a lot of content, far more content than anyone was expecting.</div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div>I have a lot of content, far more content than anyone was expecting. I will overflow if I am in a fixed height row.</div>
  <div></div>
  <div></div>
  <div></div>
</div>
body {
  font: 1.2em Arial, sans-serif;
}

.grid {
  max-width: 80vw;
  margin: 20px auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20vw, 1fr));
  grid-auto-rows: minmax(20vh, auto);
  grid-gap: 20px;
}

.grid > div {
  padding: 20px;
  background-color: #ccc;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.