title: Why does setting min-width or min-height to 0 prevent CSS flex and grid overflow?
body: <p>I had a problem when the content inside a <code>grid</code> causes the whole grid to expand. I found out (somewhere I can't remember) that setting <code>min-width</code> or <code>min-height</code> to 0 prevents that issue.</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>body {
    padding: 0;
    margin: 0;
  }
  
  .container {
    display: grid;
    width: 90vw;
    height: 90vh;
    grid-template-areas: "left right";
    grid-template-rows: 1fr;
  }
  
  .left {
    background: green;
    grid-area: left;
    /* Without this, the whole grid's height is expanded: */
    min-height: 0;
  }
  
  .left .long-content {
    width: 50px;
    background: yellow;
    height: 110vh;
  }
  
  .right {
    background: cornflowerblue;
    grid-area: right;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
    &lt;div class="left"&gt;
      &lt;div class="long-content"&gt;Tall content on the left&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="right"&gt;
      &lt;p&gt;Content Right&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>In this simple example, adding <code>overflow-y: auto</code> to <code>.left</code> also solves the problem, but it isn't the case for me in more complex layout. I learnt this applies for Flex as well sometimes ago.</p>
  <p>My question is: why?</p>
  <p>My element has content, so its width or height should already be &gt; 0 already, why is this property changing the behavior of its parent? Will this backfire in any special case I am not aware of?</p>