html - 结合 LTR 和 RTL 内容改变负数的方向

标签 html css bidi

这是我的 HTML 结构:

div{
  direction: rtl;
}

span{
  direction: ltr;
}
<div>
  <span>امروز -2</span>
  </div>

这是预期的结果:

enter image description here

如您所见,- 符号应该出现在数字的开头。我该怎么做?

注意:div的方向应该是rtl


ٍEDIT:我生成的数字是这样的:

$sums_value = sprintf("%+d",$sums_value);

/* 
sums_value = -2 //=> -2
sums_value = 2  //=> +2

所以数字的格式是正确的,但我不知道为什么它会在输出中被破坏:

enter image description here

最佳答案

由于您的屏幕截图在不同的 span 元素中有“-2”,您可以在该特定范围内使用 unicode-bidi 选项:

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.

由于您使用的是 RTL 语言,并且您希望 -2 出现在 LTR 中,因此 unicode-bidi : bidi-override 非常方便。

关于html - 结合 LTR 和 RTL 内容改变负数的方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38922249/

相关文章:

多个字符集中的 CSS 字体堆栈名称

javascript - ng-show 不适用于 bool 值

javascript - 当输入值以编程方式更改时触发更改事件?

css - 如何在具有不同 li 类的 ul-li 列表中获取特定类的最后一个 li

html - 单选按钮和文本在从右到左 (rtl) HTML 区域中的顺序是否正确?

html - 如何解决 BiDi 支架问题?

java - 阿拉伯数字在带有双向文本/数字的android textview中被反转

php - 使用下拉列表不断将多个 mysql 数据库行添加到 html 表中

html - 如何通过一次声明使字体大小响应不同大小的设备

jquery - 更改 css onclick/unclick