css text middle div code example
Example 1: center div horizontally and vertically
.parent {
position: relative;
}
.child {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
Example 2: how to center an image element inside a block in css
img { display:block;
margin-left: auto;
margin-right:auto;
}
Example 3: how to center a div element
.box1{
width:80%;
margin:0 auto;
}
Example 4: align centre
.headerTwoDiv{
margin:1% auto;
margin-right: auto; margin-left: auto; width: 21%;
padding-top: 11px;
}