How to resize images proportionally / keeping the aspect ratio?

前端 未结 18 1849
野趣味
野趣味 2020-11-22 13:58

I have images that will be quite big in dimension and I want to shrink them down with jQuery while keeping the proportions constrained, i.e. the same aspect ratio.

C

18条回答
  •  攒了一身酷
    2020-11-22 14:12

    Does help?

    Browser will take care of keeping aspect ratio intact.

    i.e max-width kicks in when image width is greater than height and its height will be calculated proportionally. Similarly max-height will be in effect when height is greater than width.

    You don't need any jQuery or javascript for this.

    Supported by ie7+ and other browsers (http://caniuse.com/minmaxwh).

提交回复
热议问题