【发布时间】:2021-05-13 21:52:51
【问题描述】:
我在下面有这条 SVG 路径线,它有两个圆圈以特定的持续时间从一端移动到另一端。是否可以更改蓝色圆圈的颜色,使其在开始时为蓝色,20 秒后开始变为白色,然后在还有 20 秒的时间到达结束,而红色圆圈会根据圆圈的颜色改变自己的颜色,然后在当前蓝色移动圆圈后面添加一个发光,这将是当前蓝色圆圈的颜色?
这是否意味着必须使用 javascript 制作整体,或者我必须如何修改 HTML 以使其按照描述的方式运行?
<svg width="450" height="450">
<path id="motionPath2"
d="M 50 200 L 400 200 "
stroke="
none" fill="transparent" />
<circle class="circle" r=20 fill=#ff0000 z-index=55>
<animateMotion dur="100s" repeatCount="indefinite"
rotate="auto">
<mpath href="#motionPath2" />
</animateMotion>
</circle>
<path id="motionPath"
d="M 50 200 L 400 200 "
stroke="
black" fill="transparent" />
<circle class="circle" r=5 fill=#45b6fe z-index=55>
<animateMotion dur="100s" repeatCount="indefinite"
rotate="auto">
<mpath href="#motionPath" />
</animateMotion>
</circle>
</svg>
【问题讨论】: