简体   繁体   English

如何使SVG中出现透明文字

[英]How to make transparent text appear in SVG

<svg>
        <text x="0" y="50" font-family="Verdana" font-size="35" fill="blue" opacity="0">Hello</text>
        <animate attributeName="opacity" begin="click" dur="0.3s" from="0" to="1" restart="never" fill="freeze"></animate>
</svg>

Above is the code, I want to use SVG to make a transparent text appear.上面是代码,我想用 SVG 让一个透明的文字出现。 I am new to coding especially SVG, thanks for any help and creative thoughts.我是编码新手,尤其是 SVG,感谢您的帮助和创造性想法。

The easiest thing is to make the animate element a child of the text element.最简单的事情是使动画元素成为文本元素的子元素。

 <svg> <text x="0" y="50" font-family="Verdana" font-size="35" fill="blue" opacity="0">Hello <animate attributeName="opacity" begin="click" dur="0.3s" from="0" to="1" restart="never" fill="freeze"></animate> </text> </svg>

Otherwise you could add a href or xlink:href attribute to the animate tag to tell it that it's the text element you want to affect否则,您可以将 href 或 xlink:href 属性添加到 animate 标记以告诉它它是您想要影响的文本元素

 <svg> <text id="t" x="0" y="50" font-family="Verdana" font-size="35" fill="blue" opacity="0">Hello </text> <animate attributeName="opacity" href="#t" begin="click" dur="0.3s" from="0" to="1" restart="never" fill="freeze"></animate> </svg>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM