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

{{InteractiveExample("CSS Demo: text-orientation")}}

```css interactive-example-choice writing-mode: vertical-rl; text-orientation: mixed;


```css interactive-example-choice writing-mode: vertical-rl; text-orientation: upright;

```html interactive-example

In another moment down went Alice after it, never once considering how in the world she was to get out again.


## 语法 ```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: unset;

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

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

形式化定义

{{CSSInfo}}

形式化语法

{{csssyntax}}

例子

HTML

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

CSS

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

结果

{{EmbedLiveSample('例子')}}