大网数据广告活动
Web 标准与前端开发

ry

· 52CE 我爱测

The **`ry`** attribute defines a radius on the y-axis.

The ry attribute defines a radius on the y-axis.

You can use this attribute with the following SVG elements:

  • ellipse
  • rect

ellipse

For ellipse, ry defines the y-radius of the shape. With a value lower or equal to zero the ellipse won't be drawn at all.

<table class="properties"> <tbody> <tr> <th scope="row">Value</th> <td> <strong ><a href="/en-US/docs/Web/SVG/Guides/Content_type#length" ><length></a ></strong > | <strong ><a href="/en-US/docs/Web/SVG/Guides/Content_type#percentage" ><percentage></a ></strong > | <code>auto</code> </td> </tr> <tr> <th scope="row">Default value</th> <td><code>auto</code></td> </tr> <tr> <th scope="row">Animatable</th> <td>Yes</td> </tr> </tbody> </table>

[!NOTE] The y-radius of the <ellipse> can also be defined with the ry geometry property. If set in CSS, the ry property value overrides the ry attribute value.

rect

For rect, ry defines the y-axis radius of the ellipse used to round off the corners of the rectangle.

The way the value of the ry attribute is interpreted depend on both the rx attribute and the width of the rectangle:

  • If a properly specified value is provided for ry but not for rx (or the opposite), then the browser will consider the missing value equal to the defined one.
  • If neither ry nor rx has a properly specified value, then the browser will draw a rectangle with square corners.
  • If ry is greater than half of the width of the rectangle, then the browser will consider the value for ry as half of the width of the rectangle.

<table class="properties"> <tbody> <tr> <th scope="row">Value</th> <td> <strong ><a href="/en-US/docs/Web/SVG/Guides/Content_type#length" ><length></a ></strong > | <strong ><a href="/en-US/docs/Web/SVG/Guides/Content_type#percentage" ><percentage></a ></strong > | <code>auto</code> </td> </tr> <tr> <th scope="row">Default value</th> <td><code>auto</code></td> </tr> <tr> <th scope="row">Animatable</th> <td>Yes</td> </tr> </tbody> </table>

[!NOTE] The vertical curve of the corners of the <rect> can also be defined with the ry geometry property. If set in CSS, the ry property value overrides the ry attribute value.

Example

html,
body,
svg {
  height: 100%;
}
<svg viewBox="0 0 300 200" xmlns="http://www.w3.org/2000/svg">
  <ellipse cx="50" cy="50" ry="0" rx="25" />
  <ellipse cx="150" cy="50" ry="25" rx="25" />
  <ellipse cx="250" cy="50" ry="50" rx="25" />

  <rect x="20" y="120" width="60" height="60" ry="0" rx="15" />
  <rect x="120" y="120" width="60" height="60" ry="15" rx="15" />
  <rect x="220" y="120" width="60" height="60" ry="150" rx="15" />
</svg>

Example

Specifications

See also

  • CSS ry property

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。