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

戏子无情 提交于 2019-12-09 02:14:11

问题


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?


回答1:


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




回答2:


Just leave

height=auto

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




回答3:


The solution was to add the typical IE fix :(

css:

height:auto !important;



回答4:


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

height=100%



回答5:


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;



回答6:


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.




回答7:


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




回答8:


For Edge browser you can use max-height, which will also work for other browsers

max-height: 100%;



回答9:


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.




回答10:


In "IE9 compatibility view - IE7 Standard Document mode" leaving off height=auto may not solve the problem. Try adding conditional CSS and in your special css file for IE ("ie.css") add a line that assigns the appropriate min-height to your affected class/element.

for example:

.IE7 .[css element] {min-height: xxxpx;}

Where xxx equals the necessary image height.




回答11:


height: initial; will work instead of using height: auto; in chrome and ie.



来源:https://stackoverflow.com/questions/8673356/ie-doesnt-support-height-auto-for-images-what-should-i-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!