text-orientation

Baseline 已广泛支持

此功能已成熟,并可在许多设备和浏览器版本上使用。自 2020 年 9 月起,所有浏览器均已提供此功能。

text-orientation CSS 属性设置一行中文本字符的方向。它只影响垂直模式下的文本(当 writing-mode 不是 horizontal-tb 时)。它对于控制使用垂直书写语言的显示以及制作垂直表格标题非常有用。

试一试

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>

语法

css
/* 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: revert;
text-orientation: revert-layer;
text-orientation: unset;

text-orientation 属性指定为以下列表中的单个关键字。

mixed

将水平书写脚本的字符顺时针旋转 90°。自然地排布垂直书写脚本的字符。默认值。

upright

自然地(直立)排布水平书写脚本的字符以及垂直书写脚本的字形。请注意,此关键字会导致所有字符都被视为从左到右:direction 的使用值被强制为 ltr

sideways

使字符像水平排布一样,但整行顺时针旋转 90°。

sideways-right

sideways 的别名,为兼容性而保留。

use-glyph-orientation

在 SVG 元素上,此关键字导致使用已弃用的 SVG 属性 glyph-orientation-verticalglyph-orientation-horizontal 的值。

正式定义

初始值mixed
应用于所有元素,除了表行组、行、列组和列
继承性
计算值同指定值
动画类型不可动画化

正式语法

text-orientation = 
mixed |
upright |
sideways

示例

HTML

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

CSS

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

结果

规范

规范
CSS Writing Modes Level 4
# text-orientation

浏览器兼容性

另见