How to resize images proportionally / keeping the aspect ratio?

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

    The resize can be achieved(maintaining aspect ratio) using CSS. This is a further simplified answer inspired by Dan Dascalescu's post.

    http://jsbin.com/viqare

    img{
         max-width:200px;
     /*Or define max-height*/
      }
    Alastair Cook
    
    Usman Khawaja

提交回复
热议问题