SVG icons in safari are blurred

前端 未结 3 1697
野的像风
野的像风 2021-02-06 07:16

I have noticed that svg icons that placed via \'img\' tag aren\'t rendered correctly in safari. They end up being all blurry. I have created a simple html page and pasted the sa

3条回答
  •  借酒劲吻你
    2021-02-06 08:02

    Maybe it will be helpful for someone - Safari can't correct render IMG tag (SVG format) for retina display - so the solution is - UP size image - the result you can see here Demo

    Костыль для сафари (in Russian)

    #svg {
      width: 20px;
      height: 21px;
    
      div {
        position: relative;
        transform: scale(0.25);
        transform-origin: 0 0;
        height: 100%;
        &:before {
          content: '';
          display: block;
          position: absolute;
          width: 400%;
          height: 400%;
          background-image: url(http://svgshare.com/i/1Le.svg);
          background-size: contain;
          background-repeat: no-repeat;
        }
      }
    }
    
    .w-img {
      width: 20px;
      height: 21px;
      img {
        height: 400%;
        width: 400%;
        vertical-align: middle;
        transform: scale(0.25);
        transform-origin: 0 0;
      }
    }
    

提交回复
热议问题