How do I center an image in flex box? I tried using justify-content and align-items to center but it didnt work.
In the code down below, i set my to a green box. I want to center the green box within the red box. Any help?
.body{
display: flex;
flex: 1;
width: 250px;
height: 250px;
background-color: blue;
padding: 10px;
}
.innerDiv1{
flex: 1;
background-color:red;
}
.innerDiv2{
flex: 1;
background-color: yellow;
}
.innerDiv3{
flex: 1;
width: 50px;
height: 50px;
background-color: green;
align-items: center; /*does not work*/
justify-content: flex-end; /*does not work*/
}
<div class = "body">
<div class = "innerDiv1">
<div class = "innerDiv3">
</div>
</div>
<div class = "innerDiv2">
</div>
</div>