CSS - text-orientation 屬性



text-orientation 屬性指定一行中文字字元的方向。

此屬性僅在垂直書寫模式下有效。此屬性主要用於垂直書寫,例如日語、中文等語言,以及建立垂直表格標題。

可能的值

  • mixed:將水平指令碼的字元順時針旋轉 90°。自然地佈置垂直指令碼的字元。預設值。

  • upright:自然地(垂直)佈置水平指令碼的字元,以及垂直指令碼的字形。

  • sideways:使字元按水平方向排列,但整行順時針旋轉 90°。

  • sideways-rightsideways 的別名,出於相容性目的而保留。

  • use-glyph-orientation:在 SVG 元素上,此關鍵字會導致使用已棄用的 SVG 屬性 glyph-orientation-vertical 和 glyph-orientation-horizontal 的值。

應用於

所有 HTML 元素,除了表格行組、行、列組和列。

DOM 語法

object.style.textOrientation =  mixed | upright | sideways ;

CSS text-orientation - 基本示例

以下示例演示瞭如何使用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>
廣告