text-orientation

翻译不完整。 请帮助我们翻译这篇文章!

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

语法

/* 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

形式化定义

初始值mixed
适用元素all elements, except table row groups, rows, column groups, and columns
是否是继承属性yes
计算值as specified
Animation typediscrete

形式化语法

mixed | upright | sideways

例子

HTML

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

CSS

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

结果

规范

Specification Status Comment
CSS Writing Modes Module Level 3
text-orientation
Proposed Recommendation Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
text-orientationChrome Full support 48
Full support 48
Full support 11
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Edge Full support 79
Full support 79
Full support 79
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Firefox Full support 41
Full support 41
No support 38 — 51
Disabled
Disabled From version 38 until version 51 (exclusive): this feature is behind the layout.css.vertical-text.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 15
Prefixed
Full support 15
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Safari Full support 14
Full support 14
Full support 5.1
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
WebView Android Full support 48
Full support 48
Full support ≤37
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Chrome Android Full support 48
Full support 48
Full support 18
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Firefox Android Full support 41
Full support 41
No support 38 — 51
Disabled
Disabled From version 38 until version 51 (exclusive): this feature is behind the layout.css.vertical-text.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Opera Android Full support 14
Prefixed
Full support 14
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Safari iOS Full support 14
Full support 14
Full support 5
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
Samsung Internet Android Full support 5.0
Full support 5.0
Full support 1.0
Prefixed
Prefixed Implemented with the vendor prefix: -webkit-
sidewaysChrome No support NoEdge No support NoFirefox Full support 44
Notes
Full support 44
Notes
Notes sideways-right has become an alias of sideways.
IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android Full support 44
Notes
Full support 44
Notes
Notes sideways-right has become an alias of sideways.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

参见