From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/htmlelement/dir/index.html | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 files/zh-cn/web/api/htmlelement/dir/index.html (limited to 'files/zh-cn/web/api/htmlelement/dir/index.html') diff --git a/files/zh-cn/web/api/htmlelement/dir/index.html b/files/zh-cn/web/api/htmlelement/dir/index.html new file mode 100644 index 0000000000..5af4c1d9f6 --- /dev/null +++ b/files/zh-cn/web/api/htmlelement/dir/index.html @@ -0,0 +1,50 @@ +--- +title: HTMLElement.dir +slug: Web/API/HTMLElement/dir +tags: + - Gecko DOM Reference +translation_of: Web/API/HTMLElement/dir +--- +
+
{{ APIRef("HTML DOM") }}
+
+ +

概述

+ +

dir属性用于获取或设置当前元素的元素内容的文本书写方向.

+ +

语法

+ +
var CurrentWritingDirection = elementNodeReference.dir;
+elementNodeReference.dir = NewWritingDirection;
+
+ +

CurrentWritingDirection是一个字符串,表示当前元素的元素内容的文本书写方向. NewWritingDirection是一个变量,表示当前元素新的文本书写方向.

+ +

dir 的值可以是ltr, 表示从左到右, 和rtl, 表示从右到左.

+ +

例子

+ +
var parg = document.getElementById("para1");
+parg.dir = "rtl";
+// 改变一个元素的元素内容的文本书写方向.
+ +

备注

+ +

元素的文本书写方向是指文本的排列顺序(目的是为了支持其他不同语言的系统). 阿拉伯语和希伯来语是典型的使用 rtl 排列顺序的语言.

+ +

一个图像文件也可以将dir属性设置为"rtl",这样的话,它的title和alt属性文字会按"rtl"顺序来显示.

+ +

当表格的dir属性设置为"rtl"时, 那么该表格的所有列将从右到左排列.

+ +
+

{{ gecko_callout_heading("7.0") }}

+ +

在Gecko 7.0 {{ geckoRelease("7.0") }}之前, 该属性的返回值不一定都是小写的.从 Gecko 7.0开始, 该属性的返回值全部为小写字母, 这也是规范中所规定的.

+
+ +

规范

+ +

W3C DOM Level 2 HTML: dir

+ +

{{ languages( { "ja": "ja/DOM/element.dir", "fr": "fr/DOM/element.dir", "pl": "pl/DOM/element.dir", "en": "en/DOM/element.dir" } ) }}

-- cgit v1.2.3-54-g00ecf