title: How can I make a flexbox container that stretches to fit wrapped items?
body: <p>I would like a <code>flex-direction: column;</code> flexbox container whose width grows to fit the containing elements.  </p>
  
  <p><a href="http://codepen.io/justinmc/pen/ZYwWMz" rel="noreferrer">In this codepen:</a></p>
  
  <p><img src="https://i.stack.imgur.com/n6xv2.png" alt="Screenshot of codepen"></p>
  
  <p>The grey div is the flexbox container, and the red divs are contained inside and layed out in columns with flexbox.  The grey div needs to expand/contract its width to perfectly contain the red children divs.  Is this possible?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    max-height: 290px;
    align-content: flex-start;
    padding: 2px;
    background: grey;
  }
  .child {
    background: red;
    width: 100px;
    height: 100px;
    margin: 2px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
    &lt;div class="child"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>