internet-explorerimagecss

max-width and max-height solution in Internet Explorer


In my page, I am using max-width and max-height.

Works fine for Firefox, Chrome, Opera, Epiphany, ect but NOT Internet Explorer.

What solution do you recommend in this case ?

I have to limit max-width of 180px and max-height of 180px.


Solution

  • Try to add this for IE max-width:

    .maxwidth {
        zoom:1;
        maxwidth:expression(
            function(t){
                var w = t.parentNode.scrollWidth;
                if (w != t.w) {
                    t.w = w;
                    var max = parseInt(t.currentStyle['max-width'], 10);
                    t.style.width = 'auto';
                    if (t.scrollWidth > max) {
                        t.style.width = max;
                    }
                }
            }(this)
        );
    }