JSFiddle - React, Tailwind, and code Playground
HTML
<div class="div1"></div>
<div class="div2"></div>
CSS
* {
margin: 0;
padding: 0;
}
.div1 {
width: 100vw;
height: 100px;
line-height: 100px;
text-align: center;
color: red;
overflow-y: scroll;
border: 1px solid #000000;
margin-bottom: 15px;
}
.div2 {
width: 100vw;
height: 100px;
line-height: 100px;
text-align: center;
color: green;
overflow-y: hidden;
border: 1px solid #000000;
margin-bottom: 15px;
}
JavaScript
var w1 = $('.div1').width();
var w2 = $('.div2').width();
$('.div1').html(w1);
$('.div2').html(w2);