Html 如何避免在 CSS 中换行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13132305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:37:38  来源:igfitidea点击:

How to avoid wrapping text in CSS

htmlcsscss-float

提问by HerrimanCoder

I have a new website I'm building and the CSS forces any text inside h2 tags to wrap whenever there is a space. Here's the site:

我有一个正在构建的新网站,CSS 会强制 h2 标签内的任何文本在有空格时换行。是网站:

And here's the problem:

这就是问题所在:

If I put "Low Fees" together without a space, and even add a few characters ("LowFeesABC"), it stays together and doesn't wrap. I don't know CSS well enough to know how to keep the text together. Any ideas?

如果我将“Low Fees”放在一起而没有空格,甚至添加几个字符(“LowFeesABC”),它会保持在一起并且不会换行。我不太了解 CSS,不知道如何将文本保持在一起。有任何想法吗?

回答by Jukka K. Korpela

It wraps because the element has a fixed width set on it and the text ”LOW FEES” does not fit into that width. Simply removing width:90pxremoves the wrapping.

它换行是因为元素上设置了固定宽度,并且文本“LOW FEES”不适合该宽度。只需移除即可width:90px去除包装。