Dividing-line background fix
by murgiaMarco
HTML
<div id="externalContainer" class="externalContainer">
<div id="rightElements" class="rightElements">
<div id="container" class="container">
<div class="button">
</div>
</div>
</div>
</div>
CSS
.externalContainer {
--variable : 40px;
display: block;
background: black;
width: 100%;
height: 20px;
}
.rightElements {
display: block;
background: blue;
width: calc(100% - var(--variable));
height:20px;
}
.container {
display: inline-block;
background: gray;
float: right;
}
.button {
position: relative;
display: block;
width: 20px;
height: 20px;
background: unset;
}
JavaScript
const elmnt = document.getElementById("container");
console.log("element :", elmnt.offsetWidth);
const externalContainer = document.getElementById("externalContainer");
externalContainer.style.setProperty('--variable', elmnt.offsetWidth + 'px')