title: How to do Flexbox's justify space-around in pure css
body: <p>How to equally space divs, not only between each other like justify, but also on the sides to the container.</p>
  
  <p>I would like to recreate flexbox's "justified" + "space-around" and "wrap" feature in pure/regular css.</p>
  
  <p>shown here (use handle to shrink):</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>.flex-container {
    display: flex;
    justify-content: space-around;
    background-color: DodgerBlue;
    flex-wrap: wrap;
  }
  
  .flex-container&gt;div {
    background-color: #f1f1f1;
    width: 100px;
    margin: 10px;
    text-align: center;
    line-height: 75px;
    font-size: 30px;
  }
  .resize {
    resize: both;
    overflow: hidden;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
  
    &lt;div class="flex-container resize"&gt;
      &lt;div&gt;1&lt;/div&gt;
      &lt;div&gt;2&lt;/div&gt;
      &lt;div&gt;3&lt;/div&gt;
      &lt;div&gt;4&lt;/div&gt;
      &lt;div&gt;5&lt;/div&gt;
      &lt;div&gt;6&lt;/div&gt;
      &lt;div&gt;7&lt;/div&gt;
      &lt;div&gt;8&lt;/div&gt;
    &lt;/div&gt;
  
    &lt;p&gt;A container with the justify-content property set to &lt;em&gt;space-around&lt;/em&gt; will display its items with the equal amount of space around them.&lt;/p&gt;
  
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My closest attempt can be found here:
  Problems: no equal spacing at the sides to the container. (use handle to shrink):</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>.my-nonflex-container {
    width: 100%;
    display: inline-block;
    background-color: DodgerBlue;
    text-align: justify;
  }
  
  .spacer {
    display: inline-block;
    margin: 0 auto;
    background-color: black;
  }
  
  .my-nonflex-container&gt;div {
    background-color: #faffff;
    width: 100px;
    margin: 10px;
    text-align: center;
    line-height: 75px;
    font-size: 30px;
  }
  
  .stretch {
    width: 100%;
    display: inline-block;
    height: 20px;
    background-color: #003060;
    color: white;
    text-align: center;
    margin-bottom: 20px;
  }
  
  .resize {
    resize: both;
    overflow: hidden;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
  
    &lt;div class="my-nonflex-container resize"&gt;
      &lt;div class="spacer"&gt;
        &lt;div&gt;1&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="spacer"&gt;
        &lt;div&gt;2&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="spacer"&gt;
        &lt;div&gt;3&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="spacer"&gt;
        &lt;div&gt;4&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="spacer"&gt;
        &lt;div&gt;5&lt;/div&gt;
      &lt;/div&gt;
      &lt;span class="stretch"&gt;stretcher workaround&lt;/span&gt;
    &lt;/div&gt;
  
  
  
    &lt;/div&gt;
  
    &lt;p&gt;A container with the text-justify property and a span-stretch to also justify "wrapped" content.&lt;/p&gt;
  
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>