JavaScript/HTML: How do I display an IMG with a set dimension and if the image is wider or taller th
Posted
by NickNick
on Stack Overflow
See other posts from Stack Overflow
or by NickNick
Published on 2010-05-06T05:42:41Z
Indexed on
2010/05/06
5:48 UTC
Read the original article
Hit count: 212
I have a bunch of images that are guaranteed to have:
- minimum width = 200px
- maximum width = 250px
- minimum height = 150px
- maximum height = 175px
What I want to do is display a consist 200px by 150px rectangle of the image while maintaining scale (no stretching or shrinking).
Which means, I might have some overflow.
How can I display the image so that it keeps porpotions to the original image size, yet displayed inside a 200x150 px window and hiding any overflow?
© Stack Overflow or respective owner