title: Prevent CSS3 flex-shrink from crushing content
body: <p>I'm trying to create a flexible layout in CSS3 with 3 boxes stacked on each other. The boxes are siblings and thus have the same parent element. The height of the first box must fit its content. The height of the following two boxes shall <strong>grow</strong> to fit their respective content until they're about to overflow their parent. In that case, they shall shrink so that they don't overflow.</p>
  
  <p>The problem is that I can't figure out how to prevent one of the shrinking boxes from becoming crushed if its content is small in relation to the other shrinking box. I want those boxes to shrink down to a certain point where they won't shrink anymore – let's say the equivalent of two rows of text for example. Setting <code>min-width</code> isn't an option because I don't want the boxes to be taller than their content in case the content is only one row for example. If any of the boxes has come to the point where it shall not shrink anymore and the parent can't hold them without overflowing, the parent shall get a scrollbar.</p>
  
  <p>I don't know the content in advance so the layout has to be dynamic. I want to solve this only with CSS, if possible.</p>
  
  <p>Here's an example of the problem where <em>box3</em> is too small:</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>p {
      margin: 0;
  }
  .container, .box {
      border: 1px solid black;
  }
  .box {
      background-color: white;
      margin: 1em;
      overflow: auto;
  }
  #container {
      background-color: yellow;
      display: flex;
      flex-direction: column;
      height: 15em;
      overflow: auto;
  }
  #box1 {
      flex: 0 0 auto;
  }
  #box2 {
  }
  #box3 {
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container" class="container"&gt;
      &lt;div id="box1" class="box"&gt;
          &lt;p&gt;◼&lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="box2" class="box"&gt;
          &lt;p&gt;◼◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◻◻◻◻◻◻◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◻◻◻◻◻◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◻◻◻◻◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◻◻◻◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◻◻◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◻◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◼◻◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◼◼◻◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◼◼◼◻◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◼◼◼◼◻◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◼◼◼◼◼◻◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◻◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◻&lt;/p&gt;
          &lt;p&gt;◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼&lt;/p&gt;
      &lt;/div&gt;
      &lt;div id="box3" class="box"&gt;
          &lt;p&gt;◼◻◻&lt;/p&gt;
          &lt;p&gt;◼◼◻&lt;/p&gt;
          &lt;p&gt;◼◼◼&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>