CSS text-orientation 属性
定义和用法
text-orientation
属性指定字符的方向。
注意:仅当 writing-mode 设置为垂直时才有效。
实例
例子 1
为不同的 <div> 元素设置文本方向:
div.a { text-orientation: mixed; } div.b { text-orientation: upright; }
例子 2
text-orientation
属性可用于更改表格表头的方向:
th { writing-mode: vertical-lr; text-orientation: upright; }
CSS 语法
text-orientation: mixed|upright|sideways|sideways-right|use-glyph-orientation|initial|inherit;
属性值
值 | 描述 |
---|---|
mixed | 默认值。字符顺时针旋转 90 度。 |
upright | 字符不旋转,保持直立。 |
sideways | 字符的方向与 writing-mode 为垂直时文本行的方向相同,即顺时针旋转 90 度。 |
sideways-right | 等于 sideways 属性值。保留用于兼容性目的。 |
use-glyph-orientation | 用于 SVG 元素,以便文本继承已弃用的 SVG 属性 glyph-orientation-vertical 和 glyph-orientation-horizontal。 |
initial | 将此属性设置为其默认值。参阅 initial。 |
inherit | 从其父元素继承此属性。参阅 inherit。 |
技术细节
默认值: | mixed |
---|---|
继承性: | yes |
动画制作: | 不支持。请参阅:动画相关属性。 |
版本: | CSS3 |
JavaScript 语法: | object.style.textOrientation="upright" |
浏览器支持
表格中的数字表示首个完全支持该属性的浏览器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
48.0 | 79.0 | 41.0 | 14.0 | 35.0 |