<div class="notice">
  👋 Hey, looks like your browser does not support <code>inset-block</code>. Try viewing this demo in Firefox.
</div>

<div class="wrapper">
  <div class="box box--inset">
    start:<br>
    <span id="output-start">0px</span>
    end:<br>
    <span id="output-end">0px</span>
  </div>
  <div class="box box--original"></div>
</div>

<div class="controls">
  <p>Slide to update the <code>inset-block-start</code> value</p>
  <div class="controls__wrapper">
    <input id="slider-start" type="range" min="0" max="150" step="1" oninput="startChange(this.value)">
  </div>
  <p>Slide to update the <code>inset-block-end</code> value</p>
  <div class="controls__wrapper">
    <input id="slider-end" type="range" min="0" max="150" step="1" oninput="endChange(this.value)">
  </div>
:root {
  --start: 0;
  --end: 0;
}

body {
  padding: 1.5rem;
}

.wrapper {
  background: #100e17;
  border-radius: 8px;
  height: 250px;
  padding: 0 15px;
  position: relative;
}

.box {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100px;
  width: 100px;
}
.box--inset {
  background: #f8a100;
  inset-block: var(--start) var(--end);
  position: relative;
  writing-mode: horizontal-lr;
}
.box--original {
  background: transparent;
  border: 1px dashed #f8a100;
  position: absolute;
  top: 0;
  bottom: 0;
}
.box span {
  font-weight: 800;
}

.notice {
  background: #fff9c4;
  border-radius: 8px;
  color: #827717;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  text-align: center;
}
.controls {
  background-color: #eaeaea;
  border-radius: 8px;
  display: none;
  grid-template-columns: 100%;
  grid-template-rows: repeat(2, 1fr);
  justify-content: center;
  margin-top: 1.5rem;
  padding: 25px 0;
  text-align: center;
  width: 100%;
}

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

input {
  margin-right: 15px;
  width: 100%;
}

@supports (inset-block-start: 0) {
  .controls {
    display: grid;
  }

  .notice {
    display: none;
  }
}
let root = document.documentElement;
const grid = document.getElementsByClassName("grid");
const sliderStart = document.getElementById("slider-start");
const sliderEnd = document.getElementById("slider-end");
const outputStart = document.getElementById("output-start");
const outputEnd = document.getElementById("output-end");

function startChange(startVal) {
  root.style.setProperty("--start", startVal + "px");
  outputStart.innerHTML = startVal + "px";
}

function endChange(endVal) {
  root.style.setProperty("--end", endVal + "px");
  outputEnd.innerHTML = endVal + "px";
}

sliderStart.value = 0;
sliderEnd.value = 0;

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.