JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Centering with position and transform </h1>
<div class="parent">
<div class="child">
PINK SQUARE SHOULD BE CENTERED.
BOTH VERTICALLY AND HORIZONTALLY
</div>
</div>
CSS
h1 { font: 13px Verdana; }
.parent {
background: linen;
width: 300px;
height: 300px;
}
.child {
background: pink;
width: 200px;
height: 200px;
display: inline-block;
position: relative;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
}