Making a piece of text non-breaking?

后端 未结 3 548
星月不相逢
星月不相逢 2020-12-08 13:06

say I have a piece of text like this

Hello I am some text Hello I am some text Hello I am some text Hello I am some text I do not wish to

相关标签:
3条回答
  • 2020-12-08 13:16

    bootstrap 4 has a class="text-nowrap"

    more here https://getbootstrap.com/docs/4.0/utilities/text/#text-wrapping-and-overflow

    0 讨论(0)
  • 2020-12-08 13:19

    Use the white-space property:

    Hello I am some text Hello I am some text Hello I am some text
    Hello I am some text <span class="nobr">I do not wish to be
    broken on new lines</span>
    

    with:

    span.nobr { white-space: nowrap; }
    
    0 讨论(0)
  • 2020-12-08 13:41

    Adding this for completeness:

    If you do not want to use CSS, you could use <nobr>text with space</nobr> - reference here

    For pure text blocks, i believe not-anymore-depricated html formatting tags like <i>, <b>, <nobr> and alike are valid for use. For content relating to the site structure use <em>, <strong> and <span class="">.

    0 讨论(0)
提交回复
热议问题