JSFiddle - React, Tailwind, and code Playground
HTML
<div class="parent">
<div class="child"></div>
</div>
<hr>
<div class="parent">
<div class="child"></div>
</div>
CSS
.parent {
width: 300px;
height: 300px;
background-color: #333;
position: relative;
}
.child {
width: 100px;
height: 100px;
background-color: #fff;
position: absolute;
top: 50%;
left: 50%;
}
.parent:nth-of-type(2) .child {
transform: translate(-50%,-50%);
}