center property css code example
Example 1: css center horizontally and vertically
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Example 2: css align center
<div class="parent">
<span>Hello World</span>
</div>
.parent {
display: flex;
justify-content: center;
align-items: center;
}
Example 3: center text in css
.class {
text-align: center;
}
Example 4: css center text
.centerText {
text-align: center;
}
Example 5: css text align center
body {
text-align: center;
}
Example 6: align centre
.headerTwoDiv{
margin:1% auto;
margin-right: auto; margin-left: auto; width: 21%;
padding-top: 11px;
}