direction - SVG: Scalable Vector Graphics 编辑

The direction attribute specifies the inline-base direction of a <text> or <tspan> element. It defines the start and end points of a line of text as used by the text-anchor and inline-size properties. It also may affect the direction in which characters are positioned if the unicode-bidi property's value is either embed or bidi-override.

It applies only to glyphs oriented perpendicular to the inline-base direction, which includes the usual case of horizontally-oriented Latin or Arabic text and the case of narrow-cell Latin or Arabic characters rotated 90 degrees clockwise relative to a top-to-bottom inline-base direction.

In many cases, the bidirectional Unicode algorithm produces the desired result automatically, so this attribute doesn't need to be specified in those cases. For other cases, such as when using right-to-left languages, it may be sufficient to add the direction attribute to the outermost <svg> element, and allow that direction to inherit to all text elements:

Note: As a presentation attribute, direction can be used as a CSS property. See css direction for further information.

As a presentation attribute, it can be applied to any element but it only has effect on shapes and text context elements, including: <altGlyph>, <textPath>, <text>, <tref>, and <tspan>.

html, body, svg {
  height: 100%;
}
<svg viewBox="0 0 600 72" xmlns="http://www.w3.org/2000/svg"
    direction="rtl" lang="fa">
  <text x="300" y="50" text-anchor="middle"
      font-size="36">داستان SVG 1.1 SE طولا ني است.</text>
</svg>

Usage notes

Valueltr | rtl
Default valueltr
AnimatableYes

Specifications

SpecificationStatusComment
CSS Writing Modes Module Level 3
The definition of 'direction' in that specification.
Proposed RecommendationDefinition in CSS
Scalable Vector Graphics (SVG) 2
The definition of 'direction' in that specification.
Candidate RecommendationRefers to the CSS Writing Modes specification of the direction property.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'direction' in that specification.
RecommendationInitial definition

Browser compatibility

BCD tables only load in the browser

See also

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

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

发布评论

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

词条统计

浏览:55 次

字数:4876

最后编辑:7 年前

编辑次数:0 次

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