开发者

CSS conditional image scaling

开发者 https://www.devze.com 2023-03-30 20:13 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消