CSS image resize percentage of itself?

前端 未结 11 2102
执念已碎
执念已碎 2020-11-28 20:46

I am trying to resize an img with a percentage of itself. For example, I just want to shrink the image by half by resizing it to 50%. But applying width: 50%; w

11条回答
  •  無奈伤痛
    2020-11-28 21:38

    Although it does not answer the question directly, one way to scale images is relative to the size (especially width) of the viewport, which is mostly the use case for responsive design. No wrapper elements needed.

    img {
        width: 50vw;
    }

提交回复
热议问题