title: Can you let child elements take 50% of the parent one level above?
body: <p>So basically I want to have some kind of gallery with multiple elements in one row, until the row is filled - then it should swap to the next row.</p>
  <p>This is all working, just the parent container of the single items has 100% height, so that the children can have 50% of that. The result is, that the padding at the bottom is not visible because the parent container does not grow with its children:</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>#container { /* should not be touched */
    height: 200px;
    width: 400px;
    overflow: auto;
  }
  
  #inner-container {
    height: 100%;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    
    background-color: green;
  }
  
  .element {
    height: 50%;
    min-width: 150px;
    
    flex-grow: 1;
    flex-basis: calc(50% - 5px);
    
    background-color: red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt;
    &lt;div id="inner-container"&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>What I have tried:</p>
  <p><code>min-height: 100%</code> instead of <code>height: 100%</code> - results in the children just taking their contents height:</p>
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#container {
    height: 200px;
    width: 400px;
    overflow: auto;
  }
  
  #inner-container {
    min-height: 100%;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    
    background-color: green;
  }
  
  .element {
    height: 50%;
    min-width: 150px;
    
    flex-grow: 1;
    flex-basis: calc(50% - 5px);
    
    background-color: red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt;
    &lt;div id="inner-container"&gt;
      &lt;div class="element"&gt;test&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>remove <code>height</code> - results in the children just taking their contents height:</p>
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#container {
    height: 200px;
    width: 400px;
    overflow: auto;
  }
  
  #inner-container {
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    
    background-color: green;
  }
  
  .element {
    height: 50%;
    min-width: 150px;
    
    flex-grow: 1;
    flex-basis: calc(50% - 5px);
    
    background-color: red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt;
    &lt;div id="inner-container"&gt;
      &lt;div class="element"&gt;test&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
      &lt;div class="element"&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <h3>Is there any way to have the inner container <code>height: 100%</code>, but grow if needed? Or just have it at <code>height: auto</code> and let the children take 50% of the <code>#container</code>?</h3>