SVG translate seems to behave different in Chrome/Chromium

后端 未结 2 949
小鲜肉
小鲜肉 2020-12-04 02:35

https://jsfiddle.net/Lpfa9umq/

Code:


    
        

        
相关标签:
2条回答
  • 2020-12-04 03:06

    <svg> within <svg> is confusing the browser. Instead use <g> tag.

    <g transform="translate(20, 10)">
        <use xlink:href="#circle2" />
    </g>
    
    0 讨论(0)
  • 2020-12-04 03:20

    In SVG 1.1 <svg> elements do not accept transform attributes. In SVG 2 it is proposed that they should.

    Chrome and Firefox are experimenting with implementing proposed parts of the SVG 2 specification. Some things are implemented only by Firefox, and others only by Chrome. The majority are not implemented at all and a few features are implemented by both. The SVG 2 specification itself is unfinished.

    In this particular case Firefox has implemented the SVG 2 feature but Chrome has not.

    You can achieve the same result in browsers that do not support this SVG 2 feature either by replacing the <svg> element by a <g> element or by creating an <svg> child element on the <g> element and putting the transform on the <g> element.

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