title: How can I hide a column when its width will be less than a certain size in CSS grid?
body: <p>I am new to CSS grid and am not sure whether it is possible to accomplish the following without resorting to using JavaScript.</p>
  
  <p>I am trying to hide a sidebar when it will be less than <code>200px</code> wide.</p>
  
  <p>But I only want to show a sidebar when <code>200px</code> is no more than <code>40%</code> of the available width.</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>.grid {
    display: grid;
    grid-template-columns: minmax(0, 200px) 1fr 0; /* what goes here ? */
    min-height: 100px;
  }
  
  .grid .sidebar {
    grid-area: 2 / 1 / 2 / 1;
    background: red;
  }
  
  .grid .main {
    grid-area: 2 / 2 / 2 / 2;
    background: blue;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="grid"&gt;
    &lt;div class="sidebar"&gt;&lt;/div&gt;
    &lt;div class="main"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>For instance, let's say <code>.grid</code> is <code>400px</code> wide. Then <code>40%</code> of <code>400px</code> is <code>160px</code>, but <code>200px</code> is more than <code>160px</code>, so <code>.sidebar</code> should either not display or have <code>0</code> width.</p>
  
  <p>But if <code>.grid</code> is <code>1000px</code> wide, then <code>40%</code> of <code>1000px</code> is <code>400px</code>. Since <code>200px</code> is less than <code>400px</code>, it should display with width of <code>400px</code>.</p>
  
  <p>Is this possible to do with just CSS grid, a combination of CSS grid and other CSS directives, or not possible without JavaScript?</p>