center a div horizontally and vertically css code example
Example 1: css flex center horizontally and vertically
display: flex;
align-items: center;
justify-content: center;
Example 2: center div horizontally and vertically
.parent {
position: relative;
}
.child {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
Example 3: centering horizontally
div.center{display:block;margin:auto;width:50%;}
p.center{text-align:center;}