JSFiddle - React, Tailwind, and code Playground
HTML
<div id="child"></div>
CSS
html, body {
margin: 0;
height: 100%;
}
#child {
width: 200px;
height: 200px;
background: black;
}
#child {
position: absolute; /* fixed */
top: 50%;
transform: translateY(-50%);
/* 对于已知高度元素,可以简写为 */
/* top: calc(50% - 200px); */
}