CSS transform on SVG Elements IE9+

前端 未结 2 739
深忆病人
深忆病人 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);
    }
    
      
    

提交回复
热议问题