title: Flexbox - Cater for 2,3 or 1 items per row
body: <p>I have a basic flexbox implementation that handle 3 columns, if 2 or 1 columns are used then it automatically fills the space to handle it..</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.grid3 {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
  }
  
  .grid3-item {
      flex-basis: 33.333%;
      text-align: center;
      flex:1;
      background:grey;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="grid3"&gt;
      &lt;div class="grid3-item"&gt;
          Some Content
      &lt;/div&gt;
      &lt;div class="grid3-item"&gt;
          Some Content
      &lt;/div&gt;
      &lt;div class="grid3-item"&gt;
          Some Content
      &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am trying to make it so that if there are more than 3 columns then they will be handled on a new row, so for example 5 columns would looks like this</p>
  
  <p><a href="https://i.stack.imgur.com/kWYMM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kWYMM.jpg" alt="enter image description here"></a></p>
  
  <p>Is it possible to achieve this using flexbox?  The items are generated dynamically so I want to be able to handle any number of potential items.</p>