Monday, June 29, 2009

Max Width and Max Height for Images in IE

.mainimage {
max-width: 400px;
max-height: 400px;
}
This works great in Firefox, Safari, Opera, and Chrome. But it doesn't work in Microsoft IE6 or IE7 or IE8
I can't believe Microsoft STILL has not made their browsers standards-compliant for simple things like max-width and max-height.

Solution That Works For All Browsers
It turns out there's a way of doing the equivalent of max-width and max-height for IE browsers. If you use the following style, it will work on all browsers:
.mainimage {
max-width: 400px;
max-height: 400px;
width: expression(this.width > 400 ? "400px" : true);
height: expression(this.height > 400 ? "400px" : true);

}
Microsoft web browsers understand the Microsoft-only, non-standard "expression" element inside CSS. The part inside parentheses must be a Javascript expression yielding the string that should be used in place of the expression() portion. No other web browsers understand it, which is good for our situation - we can check and set the width and height elements of our image with it, just for Microsoft browsers.

16 comments:

December 15, 2012 at 7:04 AM Anonymous said...

My family always say that I am killing my time here at web, except I know I am getting knowledge every day by reading thes fastidious articles.
Also see my web page > GFI Norte

March 10, 2013 at 11:33 PM Anonymous said...

I аm аctuallу thankful to the hοlder οf thiѕ website ωho has
ѕhareԁ thіs imрressіvе article at at this time.


My homepаge: green coffee extract

March 15, 2013 at 12:32 PM Anonymous said...

Hοla! I've been following your web site for some time now and finally got the bravery to go ahead and give you a shout out from Atascocita Tx! Just wanted to tell you keep up the great job!

my page: Création boutique en ligne

March 19, 2013 at 5:10 PM Anonymous said...

This makes the mixing phase a lot easier, just put in your concrete and water, and off you go by the
wheelbarrow load. The estimate you receive will be based on the
number of skips you need, what size skip you want, and how long you plan to keep it.
For faster setting concrete,
use less water, for more workability, use more water.

March 19, 2013 at 5:10 PM Anonymous said...

If one innocently applies an insufficient amount of sealer on a very porous
concrete material, the said material may not be effective at all.
Blistering heat and bitter freezing cold can crack the
toughest of concrete. It is advantageous for the customer to compare the prices for an additional dumpster rental from the normal waste removal company against
an offer made by a collector that will place a dumpster for a one-time pickup.

March 29, 2013 at 1:34 PM Anonymous said...

Saved as a favorite, I like your site!

Feel free to visit my website ... deer velvet spray

April 11, 2013 at 9:00 AM Anonymous said...

I visited multiple sites but thе audіo feature for audіo sοngs
existing at thіs web site is aсtually wonderful.


Also visit my site; Création boutique en ligne

April 13, 2013 at 5:20 PM Anonymous said...

This makes the mixing phase a lot easier, just put in your concrete and water, and off you go by the wheelbarrow load.

First, ready mixed concrete in Sunderland can help you get your construction job
done faster. And when we would cut for the plumbing work, I had to patch around that and make it solid.

April 20, 2013 at 9:51 AM Anonymous said...

Way cool! Some extгemеlу vаlid points!
I apprecіate you writing this write-up аnd thе reѕt of the ωеbѕite is
veгy gooԁ.

Here iѕ my site; vitamin shoppe coupon

April 24, 2013 at 8:27 PM Anonymous said...

Good daу! Woulԁ yοu mind іf
I shaгe your blοg with my zynga
grοup? There's a lot of folks that I think would really appreciate your content. Please let me know. Cheers

My weblog: vistaprint coupon Code

April 30, 2013 at 2:27 AM Anonymous said...

There are a few types, mainly fine, regular, or rough.

For the thick and curly hair, it is best to use the Moroccan Oil.
Black hair has a distinctive composition that makes it sensitive
to breakage. When choosing a treatment for your own hair, pick something
organically grown or natural as opposed to something fabricated.
Essential oils are very good agents to make the hair grow stronger, fuller and thicker.


Feel free to visit my web-site how to make your hair grow faster

May 2, 2013 at 7:30 PM Anonymous said...

сonstantly i useԁ to rеaԁ smаller articles which also cleаг thеir mоtivе, anԁ that
іs also happenіng wіth this аrticle whiсh I аm гeadіng аt thіs
place.

Take а look аt my blοg; create A website

May 3, 2013 at 12:29 AM Anonymous said...

Gooԁ ρost! Wе will be linkіng
to this particularlу grеаt post on our sitе.
Keep up the gooԁ writing.

Also visit mу blog post - Creare Un Sito FARE UN SITO Fare un sito

July 30, 2014 at 5:57 AM Anonymous said...

Excellent beat ! I wish to apprentice while you
amend your site, how can i subscribe for a weblog site? The account aided me a
appropriate deal. I have been a little bit familiar
of this your broadcast provided vibrant transparent idea

my weblog ... Google gives

August 7, 2014 at 3:02 AM Anonymous said...

Hello there! I know this is kinda off topic but I'd figured I'd ask.
Would you be interested in trading links or maybe guest authoring a blog article or vice-versa?
My blog addresses a lot of the same topics as
yours and I believe we could greatly benefit from each
other. If you might be interested feel free to shoot
me an email. I look forward to hearing from you!
Fantastic blog by the way!

my web site; keraplex bio funciona (hero.makdown.com)

October 19, 2014 at 7:56 AM Anonymous said...

Ray Ban Sunglasses Outlet Marc Jacobs Handbags Outlet Chanel Outlet Michael Kors Outlet Online Canada Goose Jackets Sale Christian Louboutin Outlet Mulberry
Bags (www.wallpaperhdquality.com) Hermes Birkin Mac
Cosmetics - sexywallpapers.photos, Louis Vuitton Handbags
Louis Vuitton Outlet Online (http://www.wallpaperhdquality.com) Mulberry Sale Michael Kors Outlet online Louis Vuitton Outlet Store Michael Kors Handbags Michael Kors Outlet Online Kevin Durant Shoes (www.rjfourteen.com) Louis Vuitton Outlet Online Celine Bags
canada goose jackets Louis Vuitton Outlet Online Store Jimmy Choo Shoes Online Michael Kors Outlet Stores Gucci Outlet ()
Michael Kors Outlet Online Polo Ralph Lauren Outlet Cheap Ray Ban Sunglasses the north Face outlet (http://www.wallpaperhdquality.com/profile/stzpee) Oakley Sunglasses Michael Kors Outlet Stores

Also visit my page; Cheap UGGs Boots (ilab1.korea.ac.kr)

Post a Comment