Change direction of negative number with combination of LTR and RTL content

前端 未结 3 337
感动是毒
感动是毒 2021-01-18 06:28

Here is my HTML structure:

相关标签:
3条回答
  • 2021-01-18 07:21

    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.

    0 讨论(0)
  • 2021-01-18 07:22

    The following worked for me:

    span {
      unicode-bidi: plaintext;
    }
    

    More info: https://developer.mozilla.org/en-US/docs/Web/CSS/unicode-bidi

    By the way, 'bidi' is short for bidirectional.

    0 讨论(0)
  • 2021-01-18 07:29

    You can use the before pseudo element to add a hyphen.

    q::before { 
      content: "-";
      color: blue;
    }
    
    
    <q>Some quotes</q>, he said.
    

    Will render as

    -Some quotes, he said.
    
    0 讨论(0)
提交回复
热议问题