<div class="controls">
  <p>Slide to update the <code>column-gap</code> value</p>
  <div class="controls__wrapper">
    <input id="slider" type="range" min="0" max="100" step="1" oninput="sliderChange(this.value)">
    <output id="output"></output>
  </div>
</div>

<div class="grid">
  <div class="grid-item">1</div>
  <div class="grid-item">2</div>
  <div class="grid-item">3</div>
</div>
:root {
  --column-gap: 0;
}

body {
  padding: 2rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-column-gap: var(--column-gap);
  column-gap: var(--column-gap);
}

.grid-item {
  align-items: center;
  background: orange;
  display: flex;
  height: max(200px, 25vh);
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.controls {
  background-color: #eaeaea;
  display: grid;
  grid-template-columns: 100%;
  grid-template-rows: repeat(2, 1fr);
  justify-content: center;
  padding: 25px 0;
  text-align: center;
  width: 100%;
}

.controls__wrapper {
  margin: 0 auto;
  width: 50%;
}

input {
  margin-right: 15px;
  width: 100%;
}
let root = document.documentElement;

const grid = document.getElementsByClassName("grid");
const slider = document.getElementById("slider");
const output = document.getElementById("output");

function sliderChange(val) {
  root.style.setProperty("--column-gap", val + "px");
  output.innerHTML = val + "px";
}

slider.value = 0;

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.