I have a list of items in a grid layout and the grid container has a width set, but no height set.
I want the items to populate columns until it hits the container width, then wrap into rows.
But right now I can only get it to work that way if define a height on the container.
Below is a snippet.
The grid items never wrap unless you uncomment the height rule for the container, but I want the container grow/shrink to fit after the grid wraps.
.box {
  height: 150px;
  width: 150px;
  background-color: red;
}
.container {
  width: 500px;
  /*   height: 500px; */
  background-color: blue;
  display: grid;
  grid-auto-flow: column;
  grid-gap: 5px;
  grid-template-rows: repeat(auto-fill, minmax(150px, 1fr));
}<div class="container">
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
  <div class="box"></div>
</div> 
    