CSS参考手册
写入模型 | Writing Modes
方向 | direction
direction
CSS属性设置文本,表格列和水平溢出的方向。使用rtl
表示从右到左(如希伯来语或阿拉伯语)写的语言,以及ltr
表示从左到右写的语言(如英语和大多数其他语言)。请注意,文本方向通常在文档中定义(例如,使用HTML的dir
属性),而不是直接使用direction
属性。
/* Keyword values */
direction: ltr;
direction: rtl;
/* Global values */
direction: inherit;
direction: initial;
direction: unset;
该属性设置块级元素的基本文本方向和unicode-bidi
属性创建的嵌入方向。它还设置文本的默认对齐方式,块级元素以及单元格在表格行中的流向。
与HTML中的属性dir
不同,属性direction
不会从表格列继承到表格单元格,因为CSS继承遵循文档树结构,而表格单元格在行内而不在列内。
在direction
和unicode-bidi
属性是两个唯一不受简写属性all
影响的属性。
Initial value |
ltr |
---|---|
Applies to |
all elements |
Inherited |
yes |
Media |
visual |
Computed value |
as specified |
Animation type |
discrete |
Canonical order |
the unique non-ambiguous order defined by the formal grammar |
语法
可能值
ltr
——文本和其他元素从左到右排列。这是默认值。
rtl
——文本和其他元素从右到左排列。
要想该direction
属性对内联级元素产生任何影响,该unicode-bidi
属性的值必须是embed
或override
。
形式语法
ltr | rtl
实例
blockquote {
direction: rtl;
}
规范
Specification |
Status |
Comment |
---|---|---|
CSS Writing Modes Module Level 3The definition of 'direction' in that specification. |
Candidate Recommendation |
No change. |
CSS Level 2 (Revision 1)The definition of 'direction' in that specification. |
Recommendation |
Initial definition. |
浏览器兼容性
Feature |
Chrome |
Edge |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support |
2.0 |
(Yes) |
1.0 (1.7 or earlier) |
5.5 |
9.2 |
1.3 |
Feature |
Android |
Edge |
Firefox Mobile (Gecko) |
IE Phone |
Opera Mobile |
Safari Mobile |
---|---|---|---|---|---|---|
Basic support |
1.0 |
(Yes) |
1.0 (1.0) |
6 |
8 |
3.1 |
写入模型 | Writing Modes相关
层叠样式表( Cascading Style Sheets )是一种用来表现 HTML 或 XML 等文件样式的计算机语言。CSS 不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。