我想将一行文字放在一起,这样整条线都会掉线或根本没有
可接受
How do I wrap this line of text - asked by Peter 2 days ago
可接受
How do I wrap this line of text
- asked by Peter 2 days ago
不接受
How do I wrap this line of text - asked by Peter
2 days ago
这在CSS中是否可以实现?
答案 0 :(得分:107)
您可以使用white-space: nowrap;
来定义此行为:
// 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 ;
}
答案 1 :(得分:1)
您也可以放置不间断的空格(&amp; nbsp;)来代替空格,以便它们被迫保持在一起。
How do I wrap this line of text
- asked by Peter 2 days ago