JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<style type="text/css">
div {
width: 14px;
height: 14px;
border: 1px solid blue;
background-color: red;
}
</style>
<script type="text/javascript">
var s, d;
window.onload = function() {
s = document.querySelector('span');
d = document.querySelector('div');
setInterval(updateWidth, 100);
}
function updateWidth() {
s.innerHTML = d.offsetWidth;
}
</script>
</head>
<body>
<div></div>
<p>offsetWidth of div element is: <span></span></p>
</body>
</html>