开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜