I am trying to center align all child divs inside parent div. And it works if I put display: flex;
& justify-content: center;
on my <parent-div>
But the problem is - I am expecting the last child div to be aligned to left.
But justify-content: center;
aligns the last <child-div>
in the center.
I tried removing justify-content: center;
from the <parent-div>
, and added margin: 0px 8px;
to get expected output. However, it is not responsive.
.parent-div {
display: flex;
flex-direction: row;
flex-wrap: wrap;
/* margin: 0px 8px; */
justify-content: center;
}
.child-div {
border: 1px dotted indianred;
height: 222px;
width: 156px;
}
<div class = "parent-div">
<div class = "child-div">
I am child 1
</div>
<div class = "child-div">
I am child 2
</div>
<div class = "child-div">
I am child 3
</div>
</div>