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

后端 未结 5 869
面向向阳花
面向向阳花 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 02:13

    Try adding the width and height attributes to your img's

    Also set the natural dimensions in your HTML to help the browser render.

    HTML

     
    

    CSS

      img{
           max-width: 100%
           height: auto;
        }
    

提交回复
热议问题