title: Flexbox, responsive grid of square divs maintaining aspect ratio
body: <p>I'm trying to create a 2x2 grid with divs. Some of the divs might contain an image, but it will probably be set as a background, with the option <code>background-size: cover</code>.</p>
  
  <p>Here's the pen I created: <a href="http://codepen.io/qarlo/pen/vLEprq" rel="noreferrer">http://codepen.io/qarlo/pen/vLEprq</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin: auto;
    max-width: 960px;
    width: 80%;
  }
  .container__item {
    align-content: center;
    border: 1px solid #333;
    display: flex;
    flex-basis: 1;
    font-size: 3em;
    justify-content: center;
    height: 100%;
    margin-bottom: 1em;
    min-height: 300px;
    width: 47%;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
    &lt;div class="container__item"&gt;?&lt;/div&gt;
    &lt;div class="container__item"&gt;?&lt;/div&gt;
    &lt;div class="container__item"&gt;?&lt;/div&gt;
    &lt;div class="container__item"&gt;?&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I'd like to force the divs to be squares and maintain the aspect ratio when resizing it. I was mistakenly hoping that this would have been straightforward with flexbox, but unless I'm missing something, I was wrong.</p>