是否可以强制继承SVG中的animate-elements?

时间:2012-10-29 16:10:19

标签: animation inheritance svg

您好我有以下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元素。其中一个定义没有fill-opacity(由动画更改的属性)并继承动画。另一个定义了自己的fill-opacity,它不会被动画改变。

有没有办法告诉animate元素它应该影响所有子元素,无论它们是否为更改的属性定义了自己的值?

1 个答案:

答案 0 :(得分:0)

没有。 fill-opacity是一个CSS属性,因此CSS specificity适用。更具体的子规则将始终适用。你当然可以给它自己的动画。