Internet Explorer does not comply with the maximum or maximum height

I am trying to use CSS to scale my images to exact values:

HTML:

<div id="thumbnail-container">
    <img src="sample-pic.jpg"/>
</div>

CSS

#thumbnail-container img {
    max-height: 230px;
    max-width: 200px;
}

This example sample-pic.jpgis actually 320x211.

In Firefox 11.0, this code works fine, and FF resizes sample-pic.jpgto the maximum restrictions of 230x211 specified in the CSS rule.

However, in IE 9 rules max-heightand max-widthare completely ignored, and the image is displayed as a normal size of 320x211.

How to change HTML / CSS so that both IE 9 and FF 11.0 honor these maximum limits? Thanks in advance!

+3
source share
3 answers

IE7 + supports max-widthand max-height.

http://jsfiddle.net/gaby/qE6w6/

, . (, doctype)

+4

, doctype . , HTML- , :

<!doctype html>

, IE , . <head>:

<!-- Forces user OUT of IE compatibility mode and removes "broken page" icon --> 
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

edit: , , no doctype , max-width . , , ( ).

+6

All Articles