如何强制一段文字在'方向rtl'段落内'方向ltr' [英] How to force a piece of text to be 'direction ltr' inside a 'direction rtl' paragraph

查看:415
本文介绍了如何强制一段文字在'方向rtl'段落内'方向ltr'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,电话号码始终是ltr(从左到右)。



在多语种网站上工作我需要插入一个电话号码(带有+前缀和数字以' - '分隔)在方向rtl的文本段落内(当然对于相关语言)

所以我有这样的一些东西:



.ltr #test {direction:ltr} .rtl #test {direction:rtl} #phone {direction:ltr}

 < div class =ltr >< p id =test>请致电< span id =phone> + 44-123-321< / span> < / div>< / div>< div class =rtl>< p id =test>请致电< span id =phone> 123-321< /跨度> < / div>  



当然这不起作用,因为'方向'仅适用于块元素,' span '是内联元素。我需要将电话号码放入段落中,因此我无法将' span '更改为' display:inline '



我清楚了吗?



如何使它成功?$ b $你可以在 + 符号前面使用一个unicode方向性标记字符来为算法提供提示它需要。



这些是:

$ $ p $ L $ 0x200E
RTL:0x200F

所以:

 < p id =text>请致电< span id =phone>&#x200F; + 44-123-321< /跨度>对于一些帮助< / p>  

回答更多细节。


So, phone numbers are always ltr (left to right).

Working on a multilingual website I need to insert a phone number (with a '+' prefix and numbers separated by '-') inside a text paragraph that has direction rtl (for relevant languages of course)

So I have something like this:

.ltr #test {direction:ltr}
.rtl #test {direction:rtl}
#phone {direction:ltr}

<div class="ltr"><p id="test">Please call to <span id="phone">+44-123-321</span> for some help.</p></div>
<div class="rtl"><p id="test">Please call to <span id="phone">+44-123-321</span> for some help.</p></div>

Of course this is not working because 'direction' only works for block elements and 'span' is an inline element. I need the phone number to be inside the paragraph so I can't change 'span' to 'display:inline'

I'm being clear?

How to make it work?

解决方案

You can use a unicode directionality marker character just before the + sign to give the algorithm the hint it needs.

These are:

LTR: 0x200E
RTL: 0x200F

So:

<p id="text">Please call to <span id="phone">&#x200F;+44-123-321</span> for some help</p>

See this SO answer for more details.

这篇关于如何强制一段文字在'方向rtl'段落内'方向ltr'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆