I have an image inside the container. The image has a height of 2px
and container has no defined height. For some reason the container takes 18px
of height. If I make an image 18px
high, div takes 22px
, if image is 20px
, div is 24px
. I tried to use display: block, inline and inline-block. Same thing. Then I tried display: flex and it worked. Also, I figured if I just remove the div then I will just have picture with height of 2px
.
So, my question is why the div is taking that height?
<div>
<img class="colorbar__img" src="https://i.ibb.co/ZgQjMDd/colorstripe.png" alt="Color bar" />
</div
Here is the codepen with an example: https://codepen.io/in43sh/pen/mZMBOp