.container {
display: flex;
align-items: center;
}
.vertical-center {
margin: 0;
position: absolute;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
/* 100vh = 100% Viewport Height */
body {
display: flex;
height: 100vh;
flex-direction: column;
justify-content: center;
}
/* add */ align-items: center; /*to also center horizontally.*/
/* Flex */
.center {
display: flex;
justify-content: center;
align-items: center;
}
/* Without Flex */
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
<!-- if you use Tailwindcss -->
<div class="absolute top-1/2 transform -translate-y-1/2">
</div>