IE doesn't support height=auto for images, wha

2020-03-09 07:12发布

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 something similar I can use?

11条回答
▲ chillily
2楼-- · 2020-03-09 07:55

Just leave

height=auto

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

查看更多
Summer. ? 凉城
3楼-- · 2020-03-09 07:58

There is also an IE issue when using images with height=auto within flex containers.

For me personally, the issue was caused due to the image being placed within nested flex containers. I was able to remove the parent flex container and the issue was resolved for me.

There are a few more work around solutions that people have mentioned in the page below: https://github.com/philipwalton/flexbugs/issues/75

查看更多
仙女界的扛把子
4楼-- · 2020-03-09 07:59

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.

查看更多
一纸荒年 Trace。
5楼-- · 2020-03-09 08:01

The solution was to add the typical IE fix :(

css:

height:auto !important;
查看更多
Anthone
6楼-- · 2020-03-09 08:03

I had the same problem and fixes with min-height and !important didn't work for me. My img was in a flex container. I then tried putting the img inside another, wrapping div and then height:auto worked.

查看更多
登录 后发表回答