do browsers resize image accordingly if I provide either height or width?
I am supposed to display a MxN pixels image in XxY container, a colleague suggested to only provide either height or width attribute in img tag. So according to him if I provide width browser will calculate the height and resize the image proport开发者_JAVA百科ionally. I have not see this in action and I am not sure if all the browsers support this.
From my personal experience, browsers do resize an image proportionally if you were to specify either a height or width; if you specify both, then the ratio is broken and your image will not be proportional.
However, I'm not sure how all browsers handle this... I'm sure Internet Explorer does something funky since its Internet Explorer. Anyway, here's some information on image scaling from the Mozilla Developer Network:
https://developer.mozilla.org/en/css/scaling_background_images
I hope this helps.
Yes, browsers do resize an image proportionally when you provide either width or height property.
精彩评论