CSS unicode-bidi 属性,和 direction 属性,决定如何处理文档中的双书写方向文本(bidirectional text)。比如,如果一块内容同时包含有从左到右书写和从右到左书写的文本,那么用户代理(the user-agent)会使用复杂的 Unicode 算法来决定如何显示文本。unicode-bidi 属性会覆盖此算法,允许开发人员控制文本嵌入(text embedding)。

unicode-bididirection 是仅有的两个不受 all 简写影响的属性。

注意:此属性是文档类型定义(Document Type Definition, DTD)的设计者专用的。Web 设计者与其他类似的人员不应覆盖此属性。

/* 关键字值 */
unicode-bidi: normal;
unicode-bidi: embed;
unicode-bidi: isolate;
unicode-bidi: bidi-override;
unicode-bidi: isolate-override;
unicode-bidi: plaintext;
/* 全局值 */
unicode-bidi: inherit;
unicode-bidi: initial;
unicode-bidi: unset;

初始值normal
适用元素all elements, though some values have no effect on non-inline elements
是否是继承属性
适用媒体visual
计算值as specified
Animation typediscrete
正规顺序the unique non-ambiguous order defined by the formal grammar

语法

normal
对双向算法,此元素不提供额外的嵌入级别。对于内联元素,隐式的重新排序在元素的边界上起作用。
embed
对于内联元素,该值会为双向算法打开一个额外的嵌入级别。嵌入级别的方向是由 direction 属性给出的。
bidi-override
对于内联元素,该值会创建一个覆盖;对于块容器元素,该值将为不在另一个块容器元素内的内联级别的后代创建一个覆盖。这意味着在元素内部,根据 direction 属性,重新排序是严格按照顺序排列的;双向算法的隐式部分被忽略。
isolate
这个关键字表示计算元素容器的方向时,不考虑这个元素的内容。因此,这个元素就从它的兄弟姐妹中分离出来了。当应用它的双向分辨算法的时候,它的容器元素将其视为一个或多个 U+FFFC Object Replacement Character,即像 image 一样。
isolate-override
这个关键字将 isolate 关键字的隔离行为应用于周围的内容,并将 bidi-override 关键字的覆盖行为应用于内部内容。
plaintext
这个关键字在计算元素方向的时候,不考虑父元素的双向状态,也不考虑 direction 属性的值。它是使用 Unicode 双向算法的P2和P3规则计算的。 
这个值允许按照 Unicode 双向算法显示已经格式化的数据。

正式语法

normal | embed | isolate | bidi-override | isolate-override | plaintext

例子

CSS

.bible-quote {
  direction: rtl; 
  unicode-bidi: embed; 
}

HTML

<div class="bible-quote">
  A line of text
</div>
<div>
  Another line of text
</div>

结果

规范

规范 状态 备注
CSS Writing Modes Module Level 3
unicode-bidi
Candidate Recommendation 添加属性值 plaintextisolate,和 isolate-override
CSS Level 2 (Revision 1)
unicode-bidi
Recommendation 初始定义。

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 2Edge Full support 12Firefox Full support 1IE Full support 5.5Opera Full support 9.2Safari Full support 1.3WebView Android Full support 1Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 8Safari iOS Full support 3.1Samsung Internet Android Full support Yes
isolateChrome Full support 48
Full support 48
Full support 16
Prefixed Notes
Prefixed Requires the vendor prefix: -webkit-
Notes Avoiding using -webkit-isolate. It can lock up older versions of Safari (up to version 9) and Chrome (up to version 47).
Notes Since Chrome 19, the syntax from a previous version of the specification, where the isolate keyword could be used together with bidi-override, is allowed.
Edge No support NoFirefox Full support 50
Full support 50
No support 10 — 54
Prefixed Notes
Prefixed Requires the vendor prefix: -moz-
Notes From Firefox 10 to Firefox 16 (inclusive), the isolate keyword could be used together with bidi-override, which was the syntax from a previous version of the specification. From Firefox 17, only one value is allowed. Use isolate-override instead the previous isolate bidi-override.
IE No support NoOpera No support NoSafari Full support Yes
Prefixed Notes
Full support Yes
Prefixed Notes
Prefixed Requires the vendor prefix: -webkit-
Notes Avoiding using -webkit-isolate. It can lock up older versions of Safari (up to version 9) and Chrome (up to version 47).
WebView Android Full support 48Chrome Android Full support 48Edge Mobile No support NoFirefox Android Full support 50
Full support 50
No support 10 — 54
Prefixed Notes
Prefixed Requires the vendor prefix: -moz-
Notes From Firefox 10 to Firefox 16 (inclusive), the isolate keyword could be used together with bidi-override, which was the syntax from a previous version of the specification. From Firefox 17, only one value is allowed. Use isolate-override instead the previous isolate bidi-override.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support 5.0
plaintextChrome Full support 48Edge No support NoFirefox Full support 50
Full support 50
No support 10 — 54
Prefixed Notes
Prefixed Requires the vendor prefix: -moz-
Notes Before Firefox 50, the plaintext value was ignored for vertical writing modes (bug 1302734).
Notes Before Firefox 15, plaintext didn't do anything to an inline element. The specification changed and the implementation was changed in Firefox 15.
IE No support NoOpera No support NoSafari No support NoWebView Android Full support 48Chrome Android Full support 48Edge Mobile No support NoFirefox Android Full support 50
Full support 50
No support 10 — 54
Prefixed Notes
Prefixed Requires the vendor prefix: -moz-
Notes Before Firefox 50, the plaintext value was ignored for vertical writing modes (bug 1302734).
Notes Before Firefox 15, plaintext didn't do anything to an inline element. The specification changed and the implementation was changed in Firefox 15.
Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support 5.0
isolate-overrideChrome Full support 48Edge No support NoFirefox Full support 50
Full support 50
No support 17 — 54
Prefixed
Prefixed Requires the vendor prefix: -moz-
IE No support NoOpera No support NoSafari No support NoWebView Android Full support 48Chrome Android Full support 48Edge Mobile No support NoFirefox Android Full support 50
Full support 50
No support 17 — 54
Prefixed
Prefixed Requires the vendor prefix: -moz-
Opera Android No support NoSafari iOS No support NoSamsung Internet Android Full support 5.0

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

参见

文档标签和贡献者

标签: 
此页面的贡献者: RainSlide, anjia
最后编辑者: RainSlide,