JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="fixo"></div>
</div>
CSS
body {
margin:0px;
padding:0px;
}
.container {
background: #F00;
width:100%;
height:3000px;
}
.fixo {
width:100px;
height:50px;
background:#000;
position:fixed;
}
JavaScript
var container = document.querySelector('.fixo'),
w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
container.style.top = (y / 2) - (container.clientHeight / 2) + 'px';
container.style.left = (x / 2) - (container.clientWidth / 2) + 'px';