Problem of Min & Max Height & Width in IE6

Posted: November 23, 2009 in 1

IE6 does not understand min/max of both height or width. So, if you need any of these four css properties to work in IE6, then you’ll need to feed IE6 an IE expression. Basically, they’re little snippits of javascript tailored for IE.

IE expressions don’t validate, so I like to put them in a seperate ie6.css. Alternativly, you can place them in the <head>, or feed them to IE6 with the * html hack – whatever floats your boat. Here are all three methods to feed specific rules to IE6.

min-width in IE6

div {
width:500px; /* defaults to this if JS is disabled */
width:expression(document.body.clientWidth<501?"500px":"auto");
}

max-width in IE6

div {
width:500px; /* defaults to this if JS is disabled */
width:expression(document.body.clientWidth>499?"500px":"auto");
}

min-height in IE6

div {
height:500px; /* defaults to this if JS is disabled */
height:expression(this.scrollHeight<501?"500px":"auto");
}

max-height in IE6

div {
height:500px; /* defaults to this if JS is disabled */
height:expression(this.scrollHeight>499?"500px":"auto");
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s