html - 使一段文字不间断?

标签 html css nowrap

假设我有一段这样的文字

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/

相关文章:

css - 带有空格的内联 block 元素之间的间隙 : nowrap and overflow: scroll parent element

html - 响应式网格中的空列

html - 在 jHtmlArea 中添加表格

css - 表格并不总是水平居中

css - 重新加载页面后具有不同样式的导航

html - 我的标签页菜单退出页面宽度

html - 使用 nowrap 的元素会卡在 WebKit 中的相邻元素上

javascript - 与 HTML5 应用程序相比,Phonegapped Android 应用程序无法运行

php - 如何在文件夹包含的每个HTML文件中包含单独的头文件?

jquery - 动态选择插件下拉列表中的 CSS 对齐问题