title: How to use FlexBox to make wrapped divs with percentage height
body: <p>I have the following flexbox CSS. </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>ul {
    list-style-type: none;
    padding: 0px;
    margin: 0px;
    display: flex;
    flex-wrap: wrap;
  }
  
  li {
    width: 50%; /* allows for 2 boxes per row */
    /* height: I don't know! */
    background: red;
    outline: 1px solid yellow;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ul&gt;
    &lt;li&gt;
      &lt;a&gt;Foo&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a&gt;Bar&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a&gt;Foo&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a&gt;Bar&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a&gt;Foo&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a&gt;Bar&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a&gt;Foo&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a&gt;Bar&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a&gt;Foo&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a&gt;Bar&lt;/a&gt;
    &lt;/li&gt;
  &lt;/ul&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have figured out how to make the <em>widths</em> a percentage so that 2 items appear per-row. But now I would like for the items to be the same height as whatever percentage width they end up being. Wondering how to do that.</p>
  
  <p>Ideally, the solution would allow for the following cases:</p>
  
  <ol>
  <li>Padding/margin between boxes.</li>
  <li>Border on the boxes.</li>
  <li>Just regular, where there's no padding or spacing between boxes or borders on the boxes.</li>
  </ol>
  
  <p><strong>I would like for the height to form into a square</strong>. So the question is what to do to form the divs into a square, no matter what percentage width it is. So I could have 3 or 4 divs per line, or 10 or 20 divs per line. I would like to then say "the height is x%" or something so it forms a square.</p>
  
  <p>If it's not possible to form this system into squares, then I could explicitly size them. Then the question is how to center them so they fit into some width. But I would rather solve this problem with percentage widths.</p>
  
  <p>And specifically I would like to use flexbox.</p>