用LTR和RTL内容组合来改变负数的方向 [英] Change direction of negative number with combination of LTR and RTL content
问题描述
这是我的HTML结构:
div {direction:rtl; } span {direction:ltr;}
< div& < span>امروز-2< / span> < / div>
这是预期的结果:
如您所见,
符号应该在数字的开头。
div
的方向应该是 rtl
。 生成这样的数字:
$ sums_value = sprintf(%+ d,$ sums_value);
/ *
sums_value = -2 // => -2
sums_value = 2 // => +2
所以数字有正确的格式,但我不知道为什么会被打破输出:
由于你的截图在不同的 span
元素中有-2,你可以是 unicode-bidi
选项:
div {direction:rtl;} span {direction:ltr; unicode-bidi:bidi-override;}
< div> ; امروز< span> -2< / span>< / div>
unicode-bidi
的一般思想是有能力更改文本的方向性的默认行为,其中有多种语言
由于您使用的是 RTL
语言,您希望 -2
出现在 LTR
, unicode-bidi:bidi-override
非常方便。
Here is my HTML structure:
div{
direction: rtl;
}
span{
direction: ltr;
}
<div>
<span>امروز -2</span>
</div>
This is expected result:
As you see, -
sign should come in the beginning of the number. How can I do that?
Note: The direction of div
should be rtl
.
ٍEDIT: I generate that number like this:
$sums_value = sprintf("%+d",$sums_value);
/*
sums_value = -2 //=> -2
sums_value = 2 //=> +2
So the number has right format, but I don't know why it will be broken in the output:
Since your screenshot has the "-2" in a different span
element you could is the unicode-bidi
option on that specific span:
div{
direction: rtl;
}
span{
direction: ltr;
unicode-bidi: bidi-override;
}
<div>
امروز
<span>-2</span>
</div>
The general idea of
unicode-bidi
is to have the ability to change the default behavior of directionality of the text where you have multiple languages on the same page.
Since you are using an RTL
language, and you want the -2
to appear in LTR
, the unicode-bidi: bidi-override
is very handy.
这篇关于用LTR和RTL内容组合来改变负数的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!