bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

max-width: 100%; causes IMAGES not to render at all in IE8

Open winterstetter opened this issue 14 years ago • 26 comments

This is what is happening to me and how i fixed it for now. Anyone to reproduce this, please?

/*

img { max-width: 100%; causes IMAGES not to render at all in IE8 Disable via COMMENT OUT in bootstrap.css for now !

*/

As I imagine commenting this value out will cause other problems - is there a proper fix for the issue?

Using http://netrenderer.de/index.php will help to view as Internet Explorer 8.

Thanks!

winterstetter avatar Mar 31 '12 12:03 winterstetter

Where are you seeing this problem? I have IE8 running as a VM and see no such problems.

mdo avatar Mar 31 '12 19:03 mdo

[Removed]

winterstetter avatar Mar 31 '12 19:03 winterstetter

Not sure if this helps: The issue seems to occur with .png only - .jpg seems to be fine. Confused…

winterstetter avatar Mar 31 '12 20:03 winterstetter

You'll need to declare width auto it looks like. http://stackoverflow.com/questions/1771176/ie8-non-compatibility-mode-image-with-max-width-and-heightauto

Hadn't seen this issue before today—will update the core if it comes up again.

mdo avatar Mar 31 '12 20:03 mdo

Are you saying that you want me to swap in bootstrap.css

img { max-width: 100%; border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; }

to

img { width: auto; border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; }

?

winterstetter avatar Mar 31 '12 20:03 winterstetter

I need confirmation that this is an appropriate (acceptable) fix for this issue, please.

i have added this css in my bootstrap-override.css file:

/IE8 fix STANDARD MODE/ img {width: auto; height: auto;}

Thanks!

winterstetter avatar Apr 02 '12 08:04 winterstetter

Hello

I encountered this issue too. Property max-width:100% causes images (.png) to not render in IE7 and IE8 (but they render correctly in IE9 and Chrome).

I fixed this issue by replacing max-width:100% to max-width:none.

Can you see if it is revelant to fix this issue in the next release of bootstrap please ?

Thx

lauterry avatar May 07 '12 12:05 lauterry

I've hit this problem as well, in IE 7 and IE 8. I added new wrapper CSS classes around IMG tags, and new rules:

.main-nav IMG, .change_link IMG, .btn IMG {
    max-width: none;
}

It may have something to do with elements nested inside elements (the application I'm working on is currently a hybrid of ugly table-based layout and Bootstrap 2.0.3).

hlship avatar Jun 19 '12 18:06 hlship

Mark, is this the appropriate fix for now?

img {height:auto; width:auto\9; // IE8 Fix}

will you put it in the core?

Thanks!

winterstetter avatar Jun 20 '12 06:06 winterstetter

I'm also seeing this issue as well. When are we going to see a fix for this and why is this issue closed?

joe1chen avatar Jun 27 '12 16:06 joe1chen

Mark, pls.take this one on. Thanks!

winterstetter avatar Jun 27 '12 17:06 winterstetter

Thanks @thomaswinterstetter for the css fix. I can confirm that this bug affects IE8 only.

jaywilliams avatar Aug 13 '12 16:08 jaywilliams

Possibly unrelated: max-width: 100%; distorts the zoom controls on a Google Map plugin. I am simply overriding with max-width: none;.

micahalcorn avatar Sep 24 '12 16:09 micahalcorn

Same issue here. Took me a while to figure out it was bootstrap.css causing it. :-(

tonesfrommars avatar Oct 27 '12 18:10 tonesfrommars

This issue appears to have been fixed 2 months ago: https://github.com/twitter/bootstrap/commit/8cda830eaf568be8204a96ca635c0bed373028ff

travislwatson avatar Oct 29 '12 22:10 travislwatson

This issue still present in IE9 and Firefox 16.0.2. The solution is to set max-width: auto; or max-width: none; for those browsers. Hope there will be fix in Bootstrap itself.

sindilevich avatar Nov 01 '12 15:11 sindilevich

@sindilevich -- can you provide an example? The rest of this thread is talking about an issue that affects IE7/8; your issue is possibly different.

travislwatson avatar Nov 01 '12 15:11 travislwatson

@traviswatsonws -- I have created an HTML/CSS snippet on JsFiddle to demonstrate the issue: http://jsfiddle.net/sindilevich/LyzrC . IE9 and Firefox 16.0.2 will not display an image pointed by an img tag with id image1.

The setup is as follows: there is an img tag, absolutely positioned inside of a div container. The div container itself has CSS position property set to absolute (this is required on my page, and this setting makes image disappear).

If, however, you add either max-width: inherit; or max-width: none; styling to the img (to override Bootstrap default of max-width: 100%) -- it will be displayed.

Once again, Chrome (22.0.1229.94) handles the img correctly even without overriding Bootstrap's max-width property with either none or inherit.

sindilevich avatar Nov 01 '12 19:11 sindilevich

@sindilevich -- This isn't the same issue. Your use of position: absolute in this case is an edge scenario, and AFAIK there would be no way to work around this in a generic way since parent containers don't adjust their width to accommodate absolutely positioned children. The image has a zero width parent with which to calculate its own max width. All bets are off here, which is why you're getting unpredictable results.

If bootstrap were to implement your suggestion, it would nullify the use case of the max-width code: to prevent an image from exceeding the width of its container. Therefore, your suggestion is really to remove this functionality from bootstrap. I have a feeling that request won't make it in, but feel free to try. ;-)

Realistically, in this case, you just need to override the defaults, or set a width on the container.

travislwatson avatar Nov 01 '12 19:11 travislwatson

@traviswatsonws -- Thank you for a great explanation on what causes images disappear in my case!

sindilevich avatar Nov 01 '12 19:11 sindilevich