将一行文本保持为一行 - 包装整行或根本不包含 [英] Keep a line of text as a single line - wrap the whole line or none at all

查看:114
本文介绍了将一行文本保持为一行 - 包装整行或根本不包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



可接受



 如何包装这行文本 - 由Peter问2天前



可接受

 如何换行这行文本
- 由Peter问2天前

strong>不可接受

 如何包装此行文本 - 由Peter问道
2天这是在CSS中可以实现的吗?


>解决方案

您可以使用 white-space:nowrap; 定义此行为:

  // HTML:

  .nowrap {white-space:nowrap;}  

  ; p> < span class =nowrap>如何封装此文本行< / span> < span class =nowrap>  -  Peter 2天前问问< / span> < / p>  

  // CSS:
.nowrap {
white-space:nowrap;
}


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 line of text - asked by Peter 2 days ago

Acceptable

How do I wrap this line of text 
- asked by Peter 2 days ago

Not acceptable

How do I wrap this line of text - asked by Peter 
2 days ago

Is this achievable in CSS?

解决方案

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 ;
}

这篇关于将一行文本保持为一行 - 包装整行或根本不包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆