@john-mirage
Posted
Hello,
You also can use absolute position to center an element but it will be out of the flow.
html
<div class="container">
<div class="element"></div>
</div>
css
.container {
position: relative;
width: 500px;
height: 500px;
background-color: blue;
}
.element {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 200px;
height: 200px;
background-color: red;
}