对于从右到左的显示样式,括号显示错误
html 代码
<html dir="rtl">
<p>hello (world)</p>
</html>
你会看到这样的页面:
(hello (world
但是,如果我将 html 代码更改为
<html dir="rtl">
<p>hello (world) again</p>
</html>
那么文本显示正常:
hello (world) again
任何人都可以解释为什么会发生这种情况? 如何修复第一个示例?
我的浏览器是chrome
The html code
<html dir="rtl">
<p>hello (world)</p>
</html>
you will see a page like this:
(hello (world
However,if I change the html code into
<html dir="rtl">
<p>hello (world) again</p>
</html>
Then the text displays normally:
hello (world) again
Anyone can explain why this happens?
How to fix the first example?
My browser is chrome
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您只需在最后一个括号后面添加 LRM 字符即可。 HTML 实体:
这告诉浏览器将括号解释为从左到右阅读。
You just need to add the LRM character after the last bracket. HTML entity:
This tells the browser to interpret the brackets as left-to-right reading.
或者更好的是你可以尝试使用CSS
Or better you can try in CSS
在元素前后添加 css 中的特殊 rlm 字符解决了我在 Firefox 和 Chrome 中遇到的所有情况:
Adding the special rlm character in css before and after your element solved all cases I've come across in Firefox and Chrome:
在
(
之前使用
。例如:
如果您使用 javascript/svg Dom,则
对于其他特殊字符
并调用函数
getRTLText("March / 2018","/");
Use
before(
.Ex:
if you are using javascript/svg Dom then
for other special Charactors
and call function
getRTLText("March / 2018","/");
这是从右到左文本的正确括号渲染(显然)。本文提供了更多信息。
http://www.i18nguy.com/markup/right-to-left.html
dir
属性现已弃用。This is the correct bracket rendering for right to left text (apparently). This article gives a bit more info.
http://www.i18nguy.com/markup/right-to-left.html
Thedir
attribute is now depreciated.如果有人在 WordPress 中遇到此问题,您可以尝试以下修复:
https://gist.github.com/dtbaker/ b532e0e84a8cb7f22f26
If anyone has this issue in WordPress you can try this fix:
https://gist.github.com/dtbaker/b532e0e84a8cb7f22f26