PDA

View Full Version : Limiting Image Dimensions


BigDDunc
08-23-2007, 03:18 AM
Is there anyway to limit the size of images (dimensions) via CSS?

I have looked at this example:
http://www.bigbaer.com/css_tutorials/css.scale.image.html.tutorial.htm
And although it does achive what I need partly by reducing the size of the said image, I need something along the lines of max-height max-width.

As images could be 100 x 100 or 2000 x 2000 and I want them to be <400 x <400 so any images greater then 400x400 would be resized to those dimensions.

Is this possible in CSS?


***EDIT***

Was answered, for others looking the following css:
#maxsize {
max-width:700px;
width: expression(this.width > 700 ? 700: true);
}

the width: expression is a hack for IE6.

oldcrazylegs
08-27-2007, 11:15 PM
here is one possibilty
http://www.webmasterworld.com/javascript/3351639.htm

and another
http://clagnut.com/sandbox/imagetest3/

butlins
08-28-2007, 11:04 AM
Something you'll probably already know, but your CSS won't validate with width: expression(this.width > 700 ? 700: true);
You might want to use conditional comments to create an IE-specific style sheet so that only IE gets fed the hack.