How to resize images proportionally / keeping the aspect ratio?

前端 未结 18 1947
野趣味
野趣味 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:13

    If I understand the question correctly, you don't even need jQuery for this. Shrinking the image proportionally on the client can be done with CSS alone: just set its max-width and max-height to 100%.

    Here's the fiddle: http://jsfiddle.net/9EQ5c/

提交回复
热议问题