css center items vertically and horizontally inside div code example
Example 1: center div horizontally and vertically
.parent {
position: relative;
}
.child {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
Example 2: how to horizontally and vertically center content in css
.container {
min-height: 100vh; // height of the browser viewport
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}