html center text vertically and horizontally code example
Example 1: css center image
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
Example 2: css vertical center
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.parent {
display: flex;
flex-direction: column;
justify-content: center;
}
Example 3: center with css
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}