center div by flex
HTML
<div class="parent">
<div class="child">
</div>
</div>
CSS
.parent {
width: 300px;
height: 200px;
border: 1px solid black;
display: flex;
align-items:center;
justify-content:center;
}
.child {
width: 200px;
height: 100px;
border: 1px solid red;
}