center element with margin code example
Example 1: center with css
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Example 2: css align center
.center {
margin: auto;
width: 50%;
border: 3px solid green;
padding: 10px;
}