<div class="notice">
👋 Hey, looks like your browser does not support <code>inset-inline-end</code>. Try viewing this demo in Firefox.
</div>
<div class="controls">
<p>Slide to update the <code>inset-inline-end</code> value</p>
<div class="controls__wrapper">
<input id="slider" type="range" min="0" max="150" step="1" oninput="sliderChange(this.value)">
</div>
</div>
<div class="wrapper">
<div class="box box--inset">
<output id="output"></output>
</div>
<div class="box box--original"></div>
</div>
:root {
--inset-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;
justify-content: center;
height: 100px;
width: 100px;
}
.box--inset {
background: #f8a100;
inset-inline-end: var(--inset-end);
position: relative;
writing-mode: vertical-lr;
}
.box--original {
background: transparent;
border: 1px dashed #f8a100;
position: absolute;
top: 0;
bottom: 0;
}
.controls {
background-color: #eaeaea;
border-radius: 8px;
display: none;
grid-template-columns: 100%;
grid-template-rows: repeat(2, 1fr);
justify-content: center;
margin-bottom: 1.5rem;
padding: 25px 0;
text-align: center;
width: 100%;
}
.controls__wrapper {
margin: 0 auto;
width: 50%;
}
input {
margin-right: 15px;
width: 100%;
}
.notice {
background: #fff9c4;
border-radius: 8px;
color: #827717;
margin-bottom: 1.5rem;
padding: 1.5rem;
}
@supports (inset-block-start: 0) {
.controls {
display: grid;
}
.notice {
display: none;
}
}
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("--inset-end", val + "px");
output.innerHTML = val + "px";
}
slider.value = 0;
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.