# constraining image proportions



## iworld (Nov 25, 2005)

Hey,

I am building a website and would like to know if there is a way I could upload a large image (any size) and constrain the images proportions so that it doesn't skew or stretch.

Is there a way to do this in css?


----------



## amanxman (Mar 28, 2006)

You can set ONE width/height parameter but it will always change the other within proportion.

If you set both, it'll as you know, go out of proportion.

There isn't a way to do this in CSS - i've spent ages trying...

There is some javascript around that can do it, although I've never used it - just google 'image proportion javascript' for example.

By far the best, safest and quickest way is of course to change the proportion/size of the original uploaded image, but I understand that's not always ideal...!


----------

