制作一段文字不破碎? [英] Making a piece of text non-breaking?

查看:123
本文介绍了制作一段文字不破碎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个这样的文本


你好我是一些文本你好我是一些
文本你好我有些文本您好我是
一些文本我不希望在新行上损坏

考虑上面的段落。我想要的粗体部分不能打破一条新线,如果可能的话。如果,如果它需要一个滚动条或其他东西,我想要它打破,但不打破,如果可以插入一个分页之前或之后的那段文字,以便它可以适合一行。

Consider the above paragraph. I want for the bolded part to not be broken across a new line if possible. As in, I want it to break if it would require a scrollbar or something, but not break if it is possible to insert a page-break before or after that piece of text so that it can fit on one line.

这有可能吗?我试过像 page-break-inside 等等,但它似乎没有做任何事情在firefox。

How is this possible? I have tried things like page-break-inside and such, but it doesn't seem to do anything in firefox.

推荐答案

使用 white-space 属性:

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>

其中:

span.nobr { white-space: nowrap; }

这篇关于制作一段文字不破碎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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