<h2>minmax(80px, 1fr)</h2>
<div class="container container--min">
  <div class="item">1</div>
  <div class="item">2</div>
  <div class="item">3</div>
  <div class="item">4</div>
  <div class="item">5</div>
  <div class="item">6</div>
</div>

<p>
  <label for="control">Resize:</label>
  <input type="range" id="control" value="0">
</p>
/* -------- Skip this base code -------- */
* { box-sizing: border-box; } h2 { margin: 0; font-size: 24px; } .container { display: grid; grid: '. . .'; gap: 1px; padding: 1px; border: 16px solid silver; color: white; } .item { padding: 8px; background: coral; } .container--min .item { background: royalblue; }

.container { 
  width: 0;
  grid-auto-columns: minmax(80px, 1fr); 
}
document.querySelector('#control').addEventListener('input', function(e) {
  const containerElement = document.querySelector('.container');
  const itemElement = document.querySelector('.item');
  containerElement.style.width = e.target.value + '%';
  
  if (itemElement.offsetWidth === 80) {
    containerElement.classList.add('container--min');
  } else {
    containerElement.classList.remove('container--min');
  }
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.