<div class="wrapper">
    <article class="flow">
      <h1>Intrinsic grid sizing</h1>
      <figure class="callout">
          Use the dropdown to change the column sizes between the different intrinsic sizing keywords.
      <div class="controls">
          Choose column size
          <select id="switcher">
            <option value="auto">auto</option>
            <option value="min-content">min-content</option>
            <option value="max-content">max-content</option>
            <option value="fit-content(7em)">fit-content(7em)</option>
      <div class="container" id="container">
        <div class="box">Item one</div>
        <div class="box">Item two</div>
        <div class="box">Item three has more text </div>
        <div class="box">Item four</div>
        <div class="box">Item five</div>
:root {
  --var-col: auto;

.container {
  display: grid;
  grid-template-columns: repeat(3, var(--var-col));
  grid-template-rows: 200px auto;
  gap: 10px;
  background-color: var(--color-stroke);
  padding: 1em;
  max-width: 30rem;
const switcher = document.getElementById("switcher");
const root = document.documentElement;

switcher.addEventListener("change", function (evt) {
  root.style.setProperty("--var-col", evt.target.value);

External CSS

  1. https://codepen.io/web-dot-dev/pen/abpoXGZ.css

External JavaScript

This Pen doesn't use any external JavaScript resources.