JSFiddle - React, Tailwind, and code Playground

by Luiz Carlos Vieira

HTML

<div id="teste">
    Olá mundo!
</div>

CSS

body {
    margin: 5px;
    background-color: black;
    overflow: hidden;
}

#teste {
    background-color: red;
    display:inline-block;
    width: 720px;
    height: 540px;
    color: white;
    text-align: center;
    line-height: 540px;
}

JavaScript

var adjustSize = function() {
    var oDiv = document.getElementById("teste");
    
    var iWidth = window.innerWidth - 10; // Desconta duas vezes o tamanho da borda
    var iHeight = iWidth * 0.75; // Mantém o aspecto 4:3 para a largura (width) fixa
    
    oDiv.style.width = iWidth.toString() + "px";
    oDiv.style.height = iHeight.toString() + "px";
    oDiv.style.lineHeight = oDiv.style.height;
}

window.onresize = adjustSize;
adjustSize();