css center everything code example
Example 1: center a div in css
.container {
display: flex;
justify-content: center;
align-items: center;
}
Example 2: css align items vertical center
.parent {
display: flex;
justify-content: center;
align-items: center;
}
Example 3: css center everything
body {
display: flex;
min-height: 100vh;
flex-direction: column;
justify-content: center;
align-items: center;
}
Example 4: css center text in div
parent-element {text-align:center;}
parent-element {position: relative;}
element-to-be-centered {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
Example 5: html center body
body {
display:flex; flex-direction:column; justify-content:center;
min-height:100vh;
}
Example 6: how to center text in css
.class {
text-align: center;
}