CSS text-orientation 属性指定行中文本字符的方向。
此属性仅在垂直写入模式下有效。此属性基本上可用于垂直书写,例如日语、中文,也可用于制作垂直表格标题。
可能的值
- mixed:将水平脚本的字符顺时针旋转 90°。自然地布局竖体文字的字符。默认值。
- upright:自然地(直立)布局水平文字的字符,以及垂直文字的字形。
- sideways:使字符的布局与水平布局相同,但整行顺时针旋转 90°。
- sideways-right:出于兼容性目的而保留的 sideways 别名。
- use-glyph-orientation:在 SVG 元素上,此关键字会导致使用已弃用的 SVG 属性 glyph-orientation-vertical 和 glyph-orientation-horizontal 的值。
适用于
除表行组、行、列组和列之外的所有 HTML 元素。
DOM 语法
object.style.textOrientation = mixed | upright | sideways ;
CSS 文本方向 - 基本示例
以下示例演示了如何使用 text-orientation 属性:
<html>
<head>
<style>
p {
writing-mode: vertical-rl;
text-orientation: upright;
}
</style>
</head>
<body>
<h2>Text Orientation</h2>
<p>welcome to tutorialspoint</p>
</body>
</html>