SVG tref元素
时间:2020-01-09 10:44:27 来源:igfitidea点击:
SVG的<tref>元素用于引用由<defs>元素定义的文本。这样,我们可以在SVG图像中多次显示相同的文本,而不必多次包含文本。
这是一个例子:
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<text id="theText">A text that is referenced.</text>
</defs>
<text x="20" y="10">
<tref xlink:href="#theText" />
</text>
<text x="30" y="30">
<tref xlink:href="#theText" />
</text>
</svg>
注意<text>元素(在<defs>元素内部)如何具有id属性。这个id属性值是从<tref>元素的xlink:href属性引用的。

