Scaling Images Proportionally in CSS with Max-width

后端 未结 8 1434
余生分开走
余生分开走 2021-01-31 13:39

Right now, I\'m using max-width to scale images to fit. However, they don\'t scale proportionally. Is there a way to cause this to happen? I\'m open to Javascript/jQuery.

<
8条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 14:18

    Contrary to the accepted answer, you can do this without specifying the size in the HTML. It can all be done in CSS:

    #content img { 
        max-width: 100px;
        width: 100%;
        height: auto;
    }
    

提交回复
热议问题