diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
| commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
| tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/html/global_attributes/dir | |
| parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
| download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip | |
initial commit
Diffstat (limited to 'files/zh-cn/web/html/global_attributes/dir')
| -rw-r--r-- | files/zh-cn/web/html/global_attributes/dir/index.html | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/files/zh-cn/web/html/global_attributes/dir/index.html b/files/zh-cn/web/html/global_attributes/dir/index.html new file mode 100644 index 0000000000..8f27c5ee20 --- /dev/null +++ b/files/zh-cn/web/html/global_attributes/dir/index.html @@ -0,0 +1,127 @@ +--- +title: dir +slug: Web/HTML/Global_attributes/dir +translation_of: Web/HTML/Global_attributes/dir +--- +<p class="note">{{HTMLSidebar("Global_attributes")}}</p> + +<p><a href="/en-US/docs/Web/HTML/Global_attributes">全局属性</a><strong>dir</strong>是一个指示元素中文本方向的枚举属性。它的取值如下:</p> + +<ul> + <li><span style="font-family: courier new;">ltr</span>, 指从<em>左</em>到<em>右</em>,用于那种从左向右书写的语言(比如英语);</li> + <li><span style="font-family: courier new;">rtl</span>, 指从<em>右</em>到<em>左</em>,用于那种从右向左书写的语言(比如阿拉伯语);</li> + <li><span style="font-family: courier new;">auto</span>, 指由用户代理决定方向。它在解析元素中字符时会运用一个基本算法,直到发现一个具有强方向性的字符,然后将这一方向应用于整个元素。</li> +</ul> + +<div class="note"> +<p><strong>使用说明</strong></p> + +<p>这个属性对有不同语义的{{ HTMLElement("bdo") }}元素是必须的。</p> + +<ul> + <li> + <p>这个属性在{{ HTMLElement("bdi") }}元素中<em>不可</em>继承。未赋值时,它的默认值是<span style="font-family: courier new;">auto</span>。</p> + </li> + <li> + <p>这个属性可以被CSS属性{{ cssxref("direction") }}和{{ cssxref("unicode-bidi") }}覆盖,如果CSS网页有效且该元素支持这些属性的话。</p> + </li> + <li> + <p>由于文本的方向是和内容的语义而不是和表现相关,因此有可能的话,网页开发者使用这一属性而非CSS属性是被推荐的。这样,即使在不支持CSS或禁用CSS的浏览器中,文本也会正常显示。</p> + </li> + <li> + <p>auto应当用于方向未知的数据,如用户输入的数据,最终保存在数据库中的数据。</p> + </li> +</ul> +</div> + +<h2 id="说明">说明</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', "dom.html#the-dir-attribute", "dir")}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>自上一版本{{SpecName('HTML5.1')}}没有明显变化。</td> + </tr> + <tr> + <td>{{SpecName('HTML5.1', "dom.html#the-dir-attribute", "dir")}}</td> + <td>{{Spec2('HTML5.1')}}</td> + <td>{{SpecName('HTML WHATWG')}}的快照, 和{{SpecName('HTML5 W3C')}}比没有变化</td> + </tr> + <tr> + <td>{{SpecName('HTML5 W3C', "dom.html#the-dir-attribute", "dir")}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td>{{SpecName('HTML WHATWG')}}的快照, 在 {{SpecName('HTML4.01')}}基础上增加了auto值,并且是全局属性。</td> + </tr> + <tr> + <td>{{SpecName('HTML4.01', "dirlang.html#h-8.2", "dir")}}</td> + <td>{{Spec2('HTML4.01')}}</td> + <td>被所有元素支持除了{{HTMLElement("applet")}}, {{HTMLElement("base")}}, {{HTMLElement("basefont")}}, {{HTMLElement("bdo")}}, {{HTMLElement("br")}}, {{HTMLElement("frame")}}, {{HTMLElement("frameset")}}, {{HTMLElement("iframe")}}, {{HTMLElement("param")}}和{{HTMLElement("script")}}.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{ CompatibilityTable()}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>基本支持</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>基本支持</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + <td>{{ CompatVersionUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li>全部<a href="/en-US/docs/Web/HTML/Global_attributes">全局属性</a>。</li> + <li>对应这个属性的{{domxref("HTMLElement.dir")}}。</li> +</ul> |
