When the content of a flex item is an inline element, the flex item is stretches differently then when the content is a block size like it should be.
Here's a minimal reproduction
.parent {
display: flex;
width: 300px;
height: 50px;
border: 1px solid black;
align-items: center;
}
.child {
border: 1px solid red;
}
.image {
width: 20px;
height: 20px;
border: 1px solid blue;
}
<div class="parent">
<div class="child">
<img class="image" />
</div>
</div>
This gives me the following result (no stretch a accross the cross axis)
If I change the css of the image for it to be treated as a block
.image {
width: 20px;
height: 20px;
border: 1px solid blue;
display: block;
}
In this case, the child takes the height of its content
First of all, shouldn't the child stretch accross the whole cross axis for flex items ? In this example it doesn't seem to be the case.
Second of all, why is the height of the child different based on the image being inline or block ?
Thanks.
EDIT 1:
Here's the link to the fiddle if needed https://jsfiddle.net/64vxkuqt/28/