cy - SVG: Scalable Vector Graphics 编辑
The cy
attribute define the y-axis coordinate of a center point.
Three elements are using this attribute: <circle>
, <ellipse>
, and <radialGradient>
html,body,svg { height:100% }
<svg viewBox="0 0 100 300" xmlns="http://www.w3.org/2000/svg">
<radialGradient cy="25%" id="myGradient">
<stop offset="0" stop-color="white" />
<stop offset="100%" stop-color="black" />
</radialGradient>
<circle cy="50" cx="50" r="45"/>
<ellipse cy="150" cx="50" rx="45" ry="25" />
<rect x="5" y="205" width="90" height="90" fill="url(#myGradient)" />
</svg>
circle
For <circle>
, cy
defines the y-axis coordinate of the center of the shape.
Value | <length> | <percentage> |
---|---|
Default value | 0 |
Animatable | Yes |
Note: Starting with SVG2, cy
is a Geometry Property meaning this attribute can also be used as a CSS property for circles.
ellipse
For <ellipse>
, cy
defines the y-axis coordinate of the center of the shape.
Value | <length> | <percentage> |
---|---|
Default value | 0 |
Animatable | Yes |
Note: Starting with SVG2, cy
is a Geometry Property meaning this attribute can also be used as a CSS property for ellipses.
radialGradient
For <radialGradient>
, cy
defines the y-axis coordinate of the end circle for the radial gradient.
Value | <length> |
---|---|
Default value | 50% |
Animatable | Yes |
Example
html,body,svg { height:100% }
<svg viewBox="0 0 34 10" xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient cy="0" id="myGradient000">
<stop offset="0%" stop-color="gold" />
<stop offset="50%" stop-color="green" />
<stop offset="100%" stop-color="white" />
</radialGradient>
<radialGradient cy="50%" id="myGradient050">
<stop offset="0%" stop-color="gold" />
<stop offset="50%" stop-color="green" />
<stop offset="100%" stop-color="white" />
</radialGradient>
<radialGradient cy="100%" id="myGradient100">
<stop offset="0%" stop-color="gold" />
<stop offset="50%" stop-color="green" />
<stop offset="100%" stop-color="white" />
</radialGradient>
</defs>
<rect x="1" y="1" width="8" height="8" fill="url(#myGradient000)" stroke="black" />
<rect x="13" y="1" width="8" height="8" fill="url(#myGradient050)" stroke="black" />
<rect x="25" y="1" width="8" height="8" fill="url(#myGradient100)" stroke="black" />
</svg>
Specifications
Specification | Status | Comment |
---|---|---|
Scalable Vector Graphics (SVG) 2 The definition of 'cy' in that specification. | Candidate Recommendation | Definition as a geometry property |
Scalable Vector Graphics (SVG) 2 The definition of 'cy' in that specification. | Candidate Recommendation | Definition for SVG2 paint servers. |
Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of 'cy' in that specification. | Recommendation | Initial definition for <radialGradient> |
Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of 'cy' in that specification. | Recommendation | Initial definition for <ellipse> |
Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of 'cy' in that specification. | Recommendation | Initial definition for <circle> |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论