JSFiddle - React, Tailwind, and code Playground

by Zevan

HTML

<div id="red"></div>

CSS

#red{
  position:absolute;
  left: 0px;
  top : 0px;
  background-color: red;
  border: 1px solid black;
  width : 20px;
   height : 20px; 
}

JavaScript

var b = document.getElementById("red");


window.onresize = function(){
    var windowWidth = -1, windowHeight = -1;

    if(typeof(window.innerWidth) == 'number') { //Non-IE
            windowWidth = window.innerWidth;
            windowHeight = window.innerHeight;
    } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { //IE 6+ in 'standards compliant mode'
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
    }
    //console.alert("hi");
    console.log(windowWidth);
   
    b.style.width = windowWidth + "px";
    b.style.height = windowHeight + "px";
}