JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<body>
<div class="container" id="container">
<div class="blockA" id="blockA">
</div>
<div class="blockB" id="blockB">
</div>
</div>
<div id="output" class="ouput">
</div>
</body>
</html>
CSS
.container {
display: flex;
width: 100%;
justify-content: space-between;
}
.blockA, .blockB {
width: 100px;
height: 100px;
background: red;
}
JavaScript
let container = document.getElementById("container");
let blockA = document.getElementById("blockA");
let blockB = document.getElementById("blockB");
let output = document.getElementById("output")
window.addEventListener('resize', function(event) {
let diff = container.offsetWidth - blockA.offsetWidth - blockB.offsetWidth
output.innerHTML = "Distance between two blocks: " + diff + "px";
}, true);