cx - SVG: Scalable Vector Graphics 编辑

The cx attribute define the x-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 300 100" xmlns="http://www.w3.org/2000/svg">
  <radialGradient cx="25%" id="myGradient">
    <stop offset="0"    stop-color="white" />
    <stop offset="100%" stop-color="black" />
  </radialGradient>

  <circle cx="50" cy="50" r="45"/>
  <ellipse cx="150" cy="50" rx="45" ry="25" />
  <rect x="205" y="5" width="90" height="90" fill="url(#myGradient)" />
</svg>

circle

For <circle>, cx defines the x-axis coordinate of the center of the shape.

Value<length-percentage>
Default value0
AnimatableYes

Note: Starting with SVG2 cx, is a Geometry Property, meaning this attribute can also be used as CSS property for circles.

ellipse

For <ellipse>, cx defines the x-axis coordinate of the center of the shape.

Value<length-percentage>
Default value0
AnimatableYes

Note: Starting with SVG2 cx, is a Geometry Property, meaning this attribute can also be used as CSS property for ellipses.

radialGradient

For <radialGradient>, cx defines the x-axis coordinate of the end circle for the radial gradient.

Value<length>
Default value50%
AnimatableYes

Example

html,body,svg { height:100% }
<svg viewBox="0 0 34 10" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <radialGradient cx="0" id="myGradient000">
      <stop offset="0%"   stop-color="gold" />
      <stop offset="50%"  stop-color="green" />
      <stop offset="100%" stop-color="white" />
    </radialGradient>

    <radialGradient cx="50%" id="myGradient050">
      <stop offset="0%"   stop-color="gold" />
      <stop offset="50%"  stop-color="green" />
      <stop offset="100%" stop-color="white" />
    </radialGradient>

    <radialGradient cx="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

SpecificationStatusComment
Scalable Vector Graphics (SVG) 2
The definition of 'cx' in that specification.
Candidate RecommendationDefinition as a geometry property
Scalable Vector Graphics (SVG) 2
The definition of 'cx' in that specification.
Candidate RecommendationDefinition for SVG2 paint servers.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'cx' in that specification.
RecommendationInitial definition for <radialGradient>
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'cx' in that specification.
RecommendationInitial definition for <ellipse>
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'cx' in that specification.
RecommendationInitial definition for <circle>

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:43 次

字数:7902

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文