假设我有一段这样的文字
Hello I am some text Hello I am some text Hello I am some text Hello I am some text I do not wish to be broken on new lines
考虑上面的段落。如果可能的话,我希望粗体部分不要换行。比如,如果它需要滚动条或其他东西,我希望它中断,但如果可以在该文本之前或之后插入分页符以便它可以放在一行中,我希望它不中断。
这怎么可能?我已经尝试过 page-break-inside
之类的东西,但它似乎在 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; }
关于html - 使一段文字不间断?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2359443/