从右到左显示样式错误地显示括号

use*_*722 30 html google-chrome right-to-left

HTML代码

<html dir="rtl">
<p>hello (world)</p>
</html>
Run Code Online (Sandbox Code Playgroud)

你会看到这样的页面:

(hello (world
Run Code Online (Sandbox Code Playgroud)

但是,如果我将html代码更改为

<html dir="rtl">
<p>hello (world) again</p>
</html>
Run Code Online (Sandbox Code Playgroud)

然后文本正常显示:

 hello (world) again
Run Code Online (Sandbox Code Playgroud)

有谁能解释为什么会这样?如何解决第一个例子?

我的浏览器是chrome

fre*_*der 38

您只需要在最后一个括号后添加LRM字符.HTML实体:&#x200E;

<html dir="rtl">
<body>
<p>hello (world)&#x200E;</p>
</body></html>
Run Code Online (Sandbox Code Playgroud)

这告诉浏览器将括号解释为从左到右的读数.

  • 当我看到答案时,我并不认为它是由用户手写的.很多时候它甚至都不实用(尽管反向链接可能对进一步的信息有用).在使用这个技巧时,我发现Chrome开发人员工具是一个很好的简写`&lrm;` - 更容易记住...... (4认同)
  • I was searching for this solution from long. `&#x200E;` worked for me very well. Thanks :) (2认同)

Adr*_*Ber 16

或者你可以尝试使用CSS

*:after {
    content: "\200E?";
}
Run Code Online (Sandbox Code Playgroud)


小智 5

在元素之前和之后在 css 中添加特殊的 rlm 字符解决了我在 Firefox 和 Chrome 中遇到的所有情况:

*:after {
    content: "\200E?";
}
*:before {
    content: "\200E?";
}
Run Code Online (Sandbox Code Playgroud)


tri*_*ett 2

这是从右到左文本的正确括号渲染(显然)。本文提供了更多信息。

http://www.i18nguy.com/markup/right-to-left.html

dir属性现已折旧。