有没有办法将一串文本保留在一行上,这样如果 div 宽度变小,整个字符串将下降到下一行而不是一半?
例子:
"Industry Updates - 8th
September 2013"
这通常发生在移动浏览器上,而对于较小的宽度,理想的情况是整个日期保持在一起,给出:
"Industry Updates -
8th September 2013"
那么是否有使用标签或css技巧来实现这一点?谢谢
CSS
.nowrap {
white-space: nowrap;
}
HTML
<span class="nowrap">Industry Updates -</span>
<span class="nowrap">8th September 2013</span>
任何元素都white-space: nowrap
停留在一行
您想在 HTML 标记中使用不间断空格
而不是普通空格。
"Industry Updates - 8th September 2013"