<set> - SVG: Scalable Vector Graphics 编辑
The SVG <set>
element provides a simple means of just setting the value of an attribute for a specified duration.
It supports all attribute types, including those that cannot reasonably be interpolated, such as string and boolean values. For attributes that can be reasonably be interpolated, the <animate>
is usualy preferred.
Note: The <set>
element is non-additive. The additive
and accumulate
attributes are not allowed, and will be ignored if specified.
html,body,svg { height:100%; margin:0; padding:0; }
<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
<style>
rect { cursor: pointer }
.round { rx: 5px; fill: green; }
</style>
<rect id="me" width="10" height="10">
<set attributeName="class" to="round" begin="me.click" dur="2s" />
</rect>
</svg>
Attributes
to
- This attribute defines the value to be applied to the target attribute for the duration of the animation. The value must match the requirements of the target attribute.
Value type: <anything>; Default value: none; Animatable: no
Animation Attributes
- Animation timing attributes
begin
,dur
,end
,min
,max
,restart
,repeatCount
,repeatDur
,fill
- Other Animation attributes
- Most notably:
attributeName
- Animation event attributes
- Most notably:
onbegin
,onend
,onrepeat
Global attributes
- Core Attributes
- Most notably:
id
- Styling Attributes
class
,style
- Event Attributes
- Global event attributes, Document element event attributes
Usage notes
Categories | Animation element |
---|---|
Permitted content | Any number of the following elements, in any order: Descriptive elements |
Specifications
Specification | Status | Comment |
---|---|---|
SVG Animations Level 2 The definition of '<set>' in that specification. | Editor's Draft | |
Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of '<set>' in that specification. | Recommendation | Initial definition |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论