Managing justify-content: space-between on last row
<p>I am aiming to have three flex items per row and use <code>space-between</code> so the first and third items in each row touch the outside of the container but remain equally spaced.</p>

<p>This works as intended but the problems arise in the second row when the fifth item doesn't align as I want, directly below the second item. I will have a variable amount of content so need the layout to work with any number of boxes.</p>

<p>I have shown my code below. Can anyone tell me how to fix this?</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>.main{
    background: #999;
    margin:0 auto;
    width:1300px;
    display:flex;
    flex-wrap: wrap;
    justify-content: space-between;
}


.box{
    background: #7ab9d7;
    color: #555;
    height: 300px;
    width: 30%;
    margin-bottom: 30px;
    text-align: center;
    font-size: 30px;
    padding-top: 120px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="main"&gt;
         
          &lt;div class="box"&gt;1&lt;/div&gt;
          &lt;div class="box"&gt;2&lt;/div&gt;
          &lt;div class="box"&gt;3&lt;/div&gt;
          &lt;div class="box"&gt;4&lt;/div&gt;
          &lt;div class="box"&gt;5&lt;/div&gt;
         
&lt;/div&gt;</code></pre>
</div>
</div>
</p>