title: How can I get grid items to fit/share the screen size dynamically?
body: <p>I am currently building a game and want to create a split screen
  from the current version I have (which runs on a canvas) and stumbled into
  <a href="/questions/tagged/css-grid" class="post-tag" title="show questions tagged &#39;css-grid&#39;" rel="tag">css-grid</a>. </p>
  
  <p>How I can get the grid to autosize elements inside it to equally match the size of the current <code>viewport</code> / page?</p>
  
  <ul>
  <li>uf there is only one, then it should be the size of the page </li>
  <li>if there are two, then it should be half the width and be side by side</li>
  <li>third should start the second row and be half height and full width </li>
  <li>four should be 1/4 all around.</li>
  </ul>
  
  <p>then the trend continues for the rest.</p>
  
  <p>If you are familiar with split screen games you might know the layout I am talking about.</p>
  
  <p>The code below works perfectly with 4 screens; I do not know how this would be achieved with 1-2-3...-5-6-7, etc.</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>.wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    padding-left: 0;
    padding-right: 0;
    margin-left: auto;
    margin-right: auto;
  }
  
  .wrapper canvas {
    width: 100%;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="wrapper" class="wrapper"&gt;
    &lt;canvas id="canvas" width="3840" height="2160"&gt;&lt;/canvas&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The question has been answered using a flexbox instead, however, it would be nice to see the grid perform this task as well.</p>