CSS direction 属性定义及用法
定义和用法
direction 属性规定文本的方向 / 书写方向。
该属性指定了块的基本书写方向,以及针对 Unicode 双向算法的嵌入和覆盖方向。不支持双向文本的用户代理可以忽略这个属性。
默认值: | ltr |
---|---|
继承性: | yes |
版本: | CSS2 |
JavaScript 语法: | object.style.direction="rtl" |
实例
把文本方向设置为“从右向左”:
源代码:
p.one
{
direction: rtl
}
p.two
{
direction: ltr
}
<p class="one">Some text. Right-to-left direction.</p>
<p class="two">Some text. Left-to-right direction.</p>
输出后效果:
浏览器支持
所有浏览器都支持 direction 属性。
注释:任何的版本的 Internet Explorer (包括 IE8)都不支持属性值 "inherit"。
可能的值
值 | 描述 |
---|---|
ltr | 默认。文本方向从左到右。 |
rtl | 文本方向从右到左。 |
inherit | 规定应该从父元素继承 direction 属性的值。 |