嗨,我有以下 SVG 文件:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="150" height="150" viewBox="0 0 150 150">
<text x="10" y="100" fill="blue" fill-opacity="1">
<tspan fill-opacity="1" >1st</tspan>
<tspan >2nd</tspan>
<animate attributeName="fill-opacity" calcMode="discrete" values="0; 1" dur="1s" repeatCount="indefinite"/>
</text>
</svg>
如您所见,animate元素中有一个元素text,效果很好。然而,问题在于tspan元素。其中之一定义 no fill-opacity(由动画更改的属性)并继承动画。另一个定义了自己的fill-opacity,不会被动画改变。
有没有办法告诉animate元素它应该影响所有子元素,而不管它们是否为更改的属性定义了自己的值?