title: How to get the effect of grid layout's grid-template-columns with a variable number of columns?
body: <p>I have a div containing a variable number of children. This code is generated and I can't modify it. So with only CSS I need to display divs in a table with two rows:</p>
  
  <ul>
  <li>The first row contains only the first div (100% width)</li>
  <li>The other div share the second row : each div will have the same width an the should totally fill the row.</li>
  </ul>
  
  <p>I tried with a grid layout + grid-template-columns but using grid-template-columns does not because because it supposes I know the number of columns. For example, the following snippet only works if there are 4 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>.parent {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
  }
  
  .child:nth-child(1) {
      grid-column: 1/-1;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Test with 3 children
  &lt;div class="parent" style="background-color:yellow;" &gt;
    &lt;div class="child" style="background-color:red;"&gt;1&lt;/div&gt;
    &lt;div class="child" style="background-color:blue;"&gt;2&lt;/div&gt;
    &lt;div class="child" style="background-color:green;"&gt;3&lt;/div&gt;
  &lt;/div&gt;
  Test with 4 children
  &lt;div class="parent" style="background-color:yellow;" &gt;
    &lt;div class="child" style="background-color:red;"&gt;1&lt;/div&gt;
    &lt;div class="child" style="background-color:blue;"&gt;2&lt;/div&gt;
    &lt;div class="child" style="background-color:green;"&gt;3&lt;/div&gt;
    &lt;div class="child" style="background-color:orange;"&gt;4&lt;/div&gt;
  &lt;/div&gt;
  Test with 5 children
  &lt;div class="parent" style="background-color:yellow;" &gt;
    &lt;div class="child" style="background-color:red;"&gt;1&lt;/div&gt;
    &lt;div class="child" style="background-color:blue;"&gt;2&lt;/div&gt;
    &lt;div class="child" style="background-color:green;"&gt;3&lt;/div&gt;
    &lt;div class="child" style="background-color:orange;"&gt;4&lt;/div&gt;
    &lt;div class="child" style="background-color:purple;"&gt;5&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>