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

text-orientation

· 52CE 我爱测

**`text-orientation`** CSS 属性设定行中字符的方向。但它仅影响纵向模式(当 writing-mode 的值不是`horizontal-tb`)下的文本。此属性在控制使用竖排文字的语言的显示上很有作用,也可以用来构建垂直的表格头。

text-orientation CSS 属性设定行中字符的方向。但它仅影响纵向模式(当 writing-mode 的值不是horizontal-tb)下的文本。此属性在控制使用竖排文字的语言的显示上很有作用,也可以用来构建垂直的表格头。

CSS Demo: text-orientation

writing-mode: vertical-rl;
text-orientation: mixed;
writing-mode: vertical-rl;
text-orientation: upright;
<section class="default-example" id="default-example">
  <div class="transition-all" id="example-element">
    <p>
      In another moment down went Alice after it, never once considering how in
      the world she was to get out again.
    </p>
  </div>
</section>

语法

/* Keyword values */
text-orientation: mixed;
text-orientation: upright;
text-orientation: sideways-right;
text-orientation: sideways;
text-orientation: use-glyph-orientation;

/* Global values */
text-orientation: inherit;
text-orientation: initial;
text-orientation: unset;

text-orientation 应当被设置为上述关键字之一。

值

  • mixed
    • : 默认值。顺时针旋转水平书写的字符 90°,将垂直书写的文字自然布局。
  • upright
    • : 将水平书写的字符自然布局(直排),包括垂直书写的文字(as well as the glyphs for vertical scripts)。注意这个关键字会导致所有字符被视为从左到右,也就是 direction 被强制设为 ltr。
  • sideways
    • : 所有字符被布局为与水平方式一样,但是整行文本被顺时针旋转 90°。
  • sideways-right
    • : 处于兼容目的,sideways 的别名。
  • use-glyph-orientation
    • : 对于 SVG 元素,这个关键字导致使用已弃用的 SVG 属性。 glyph-orientation-vertical 和 glyph-orientation-horizontal。

形式化定义

形式化语法

例子

HTML

<p>Lorem ipsum dolet semper quisquam.</p>

CSS

p {
  writing-mode: vertical-rl;
  text-orientation: upright;
}

结果

例子

规范

浏览器兼容性

参见

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

资料来源与适用范围

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

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

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