Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

resize image only if too big [duplicate]

Tags:

html

Possible Duplicate:
Set image max size

I have an area of 100x150 px to display an image.

If the image to display is larger than this area, it should be resized (constraining width and height) to fit in the area, however when it is smaller than the area, it should remain in the original size.

Is this possible to do in HTML? or do I need to resize the image in serverside?

like image 519
Allie Avatar asked Dec 06 '22 10:12

Allie


1 Answers

Just specify the max-width and max-height styles:

img {
    max-width: 100px;
    max-height: 150px;
}
like image 166
BenM Avatar answered Jan 15 '23 22:01

BenM