Keep a line of text as a single line - wrap the whole line or none at all

前端 未结 2 1555
小蘑菇
小蘑菇 2021-01-31 00:57

I\'d like to keep a line of text together such that either the whole line drops down a line or none at all

Acceptable

How do I wrap this         


        
相关标签:
2条回答
  • 2021-01-31 01:40

    You could also put non-breaking spaces ( ) in lieu of the spaces so that they're forced to stay together.

    How do I wrap this line of text
    - asked by Peter 2 days ago
    
    0 讨论(0)
  • 2021-01-31 01:43

    You can use white-space: nowrap; to define this behaviour:

    // HTML:
    

    .nowrap {
      white-space: nowrap ;
    }
    <p>
          <span class="nowrap">How do I wrap this line of text</span>
          <span class="nowrap">- asked by Peter 2 days ago</span>
        </p>

    // CSS:
    .nowrap {
      white-space: nowrap ;
    }
    
    0 讨论(0)
提交回复
热议问题