Img's max-height not respecting parent's dimensions

后端 未结 5 872
面向向阳花
面向向阳花 2020-12-04 01:33

I have an img element inside a liquid div. That img has its max-height set to 100%. So, if the image is taller than the div, it should

5条回答
  •  天涯浪人
    2020-12-04 01:55

    If you still want the container to be % based and not px, you can make the container display: flex, and the image

    object-fit: contain;
    max-width: 100%;
    

提交回复
热议问题