How to set an image's width and height without stretching it?

前端 未结 12 1589
南旧
南旧 2020-11-28 05:22

If I have:

#logo {
    width: 400px;
    height: 200px;
}

then


12条回答
  •  孤城傲影
    2020-11-28 05:41

    #logo {
        width: 400px;
        height: 200px;
    
        /*Scale down will take the necessary specified space that is 400px x 200px without stretching the image*/
        object-fit:scale-down;
    }
    

提交回复
热议问题