CSS transform on SVG Elements IE9+

前端 未结 2 735
深忆病人
深忆病人 2021-02-05 05:13

Having a SVG Path:



        
相关标签:
2条回答
  • 2021-02-05 06:09

    IE11 supports the transform attribute in SVG even though it doesn't recognize the CSS style.

    Fortunately, you can simply set the attribute to match the style using JavaScript:

    var g = document.querySelector('.st8'),
        transform = getComputedStyle(g).getPropertyValue('transform');
        
    g.setAttribute('transform', transform);
    .st8 {
        -ms-transform: rotate(45deg); /* doesn't work on IE */
        transform: rotate(45deg);
    }
    <svg>
      <path class='st8' d='M73.4,11.3c-6.3,0-6.4,3.6-6.4,3.6v18c0,0,0.6,3.3,6.4,3.3c5.8,0,6.6-3.3,6.6-3.3v-18 C80,14.9,79.7,11.3,73.4,11.3z M75,31.3c0,0-0.3,1.2-1.6,1.2c-1.3,0-1.4-1.2-1.4-1.2V16.6c0,0,0.3-1.3,1.5-1.3s1.5,1.3,1.5,1.3V31.3 z'/>
    </svg>

    0 讨论(0)
  • 2021-02-05 06:09

    Although IE9+ support CSS3 transforms, they don't support them on SVG and to the best on my knowledge it can't be done in CSS.

    source: caniuse under known issues for CSS3 Transforms http://caniuse.com/#feat=transforms2d

    0 讨论(0)
提交回复
热议问题