direction 属性设置文本、表格列和水平溢出的方向。
可能的值
- ltr - 文本和其他元素将从左到右呈现。这是默认值。
- rtl - 文本和其他元素将从右到左呈现。它用于具有从右到左脚本的语言。
要使 direction 属性对内联级元素产生任何影响,必须嵌入或覆盖 unicode-bidi 属性的值。
适用于
所有 HTML 元素。
DOM 语法
object.style.direction = "ltr";
CSS 方向 - ltr 值
以下示例演示了 direction:ltr:
<html>
<body>
<h2>CSS direction - ltr Value</h2>
<p style = "direction:ltr;">
Text-direction - Left-to-right
</p>
</body>
</html>
CSS 方向 - rtl 值
以下示例演示了 direction:rtl:
<html>
<body>
<h2>CSS direction - rtl Value</h2>
<p style = "direction:rtl;">
Text direction - Right-to-left
</p>
</body>
</html>