SVG fills in external file

后端 未结 1 1113
故里飘歌
故里飘歌 2021-01-23 07:10

Really basic SVG question. I have read SVG sprite in external file and it works fine for me to add a svg graphic, but I can\'t get it to work with defs. First the f

相关标签:
1条回答
  • 2021-01-23 07:46

    xlink:href="defs.svg#patternDefs" should be xlink:href="defs.svg#pattern1"

    On top of that <use> has to point to something to be rendered, not a pattern. If you want to fill a circle with a pattern just set the circle's fill to the pattern. E.g.

    <svg>
        <circle cx="80" cy="80" r="50" stroke-width="2" stroke="red" fill="url(defs.svg#pattern1)" />
    </svg>
    

    Note that external fills are not widely supported, although they do work on Firefox for instance.

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