JSFiddle - React, Tailwind, and code Playground

by lollero

HTML

<div></div>

CSS

html, body {
    margin: 0px;
    padding: 0px;
}

div {
    background: #333;
    width: 10px;
    height: 10px;
}

JavaScript

var div = $('div');

$(window).on("resize", function( e ) {

    var $this = $(this),
        winH = $this.height(),
        winW = $this.width();

    div.css({
        width: winW / 2,
        height: winH / 2
    }).css({
        marginTop: ( winH / 2 ) - ( div.height() / 2 ),
        marginLeft: ( winW / 2 ) - ( div.width() / 2 ),
    });
    
}).trigger('resize');