IE doesn't support height=auto for images, what should I use?

前端 未结 11 931
太阳男子
太阳男子 2021-01-03 22:51

I have some images with height=auto because sometimes they are different heights whereas they are always the same width. It works in every browser but I.E., is there someth

相关标签:
11条回答
  • 2021-01-03 23:31

    Use height: auto together with width: auto and it is going to work in IE. If you specify only one of them, IE gets upset.

    height: auto;
    width: auto;
    
    0 讨论(0)
  • 2021-01-03 23:31

    You can do width="100%" and max-width="100px" or whatever width you want and then simply height="auto". This worked for me.

    BTW you may need min-width width your wanted width too if your parent element doesn't have the width that you want for your image.

    0 讨论(0)
  • 2021-01-03 23:32

    Just leave

    height=auto
    

    out. If it's not given it's "auto" by default...

    0 讨论(0)
  • 2021-01-03 23:39

    i've tried all the solutions posted, and the only one that works is

    height=100%
    
    0 讨论(0)
  • 2021-01-03 23:44

    I found that adding min-height:1px solves the issue. Not sure why, but, worked for me.

    0 讨论(0)
  • 2021-01-03 23:46

    The solution was to add the typical IE fix :(

    css:

    height:auto !important;
    
    0 讨论(0)
提交回复
热议问题