<section class="grid">
  <div class="item">item1</div>
  <div class="item">item2</div>
  <div class="item">item3</div>
  <div class="item">item4</div>
  <div class="item">item5</div>
</section>
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 100px);
  grid-gap: 20px;
}

External CSS

  1. https://codepen.io/matuzo/pen/vmpaWe.css

External JavaScript

This Pen doesn't use any external JavaScript resources.