css center divs code example
Example 1: center a div in css
.container {
display: flex;
justify-content: center;
align-items: center;
}
Example 2: center div css
.center {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Example 3: html center body
body {
max-width: max-content;
margin: auto;
}
Example 4: center text in div container
text-align: center
Example 5: css text align center
body {
text-align: center;
}
Example 6: align a div in center of another div
#container {
width: 640px; /*can be in percentage also.*/
height: auto;
margin: 0 auto;
padding: 10px;
position: relative;
}