CSS image resize percentage of itself?

前端 未结 11 2137
执念已碎
执念已碎 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:37

    This is a very old thread but I found it while searching for a simple solution to display retina (high res) screen capture on standard resolution display.

    So there is an HTML only solution for modern browsers :

    
    

    This is telling the browser that the image is twice the dimension of it intended display size. The value are proportional and do not need to reflect the actual size of the image. One can use 2w 1px as well to achieve the same effect. The src attribute is only used by legacy browsers.

    The nice effect of it is that it display the same size on retina or standard display, shrinking on the latter.

提交回复
热议问题