I am trying to fit images inside flexbox items and want the outer div to adjust to the height of the image height. But somehow, the outer div is slightly heigher than the image and I don't know what is causing that.
My HTML:
<div class="flex-container">
<div class="item">
</div>
<div class="item">
<img class="img-responsive" src="http://via.placeholder.com/1920x1080">
</div>
<div class="item">
<img class="img-responsive" src="http://via.placeholder.com/1920x1080">
</div>
<div class="item">
</div>
</div>
The CSS:
.flex-container {
display: flex;
flex-wrap: wrap;
}
.item {
width: 50%;
}
.img-responsive {
width: 100%;
height: auto;
}
And the result:
The images should touch at the edges but instead there's a gap. I already tried to set the margin and padding to 0 without success.
It would be great if someone could explain what is causing that.
Thanks!