JSFiddle - React, Tailwind, and code Playground

by techiedelight

HTML

<div id="container" class="main-class"></div>

CSS

.main-class {
  border: 1px solid gray;
  width: 500px;
  height: 100px;
  padding: 10px;
}

JavaScript

var rect = document.getElementById('container').getBoundingClientRect();
var height = rect.height;
var width = rect.width;

alert(`${width} x ${height}`);