CSS conditional image scaling
Is there a way to scale down an image only if width is higher than XX pixels,开发者_高级运维 in HTML/CSS ?
You can use max-width
or max-height
to specify the largest you want the image to be.
live demo
References
https://developer.mozilla.org/En/CSS/Max-height
https://developer.mozilla.org/En/CSS/Max-width
As noted in the comments this is not supported in IE6 or below.
Use max-width in your css to fix a maximum image width and don't specify your image height. This way your image should stay proportionnal and respect a max width.
精彩评论