Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange Chrome image resizing behaviour

I'm having some weird behaviour with chrome regarding image resizing when the window is resized.

When Chrome is snapped fullscreen in Windows(double click the window to snap full screen), and I unsnap the window, causing it to revert to whatever previous size it was unsnapped, images are not being scaled properly.

For example, I have the following css code that resizes images to 100% height of the space available, and auto's the width:

img{
    height: 100%
    width: auto;
}

When the window is snapped fullscreen it looks fine, the aspect ratio's of the images are kept. But now if I unsnap the window (double click). The height will resize, the width will not, like below: Unsnap full screen in Chrome

Whereas in Internet Explorer, unsnapping looks like this: Unsnapping fullscreen in IE

Anyone know why chrome is not resizing properly? Or is there something wrong with my css?

If you need more code please ask.

Thanks.

like image 873
SikhWarrior Avatar asked Apr 24 '14 00:04

SikhWarrior


1 Answers

Use instead width:100% -> max-width:100%;

I had before this issue once, and I have used both properties of size

img{
    max-width:100%;
    max-height:100%;
}

It works for me just fine, and save the proportion.

like image 113
Elad Shechter Avatar answered Nov 02 '22 16:11

Elad Shechter