我知道这个网站上已经发布了相关问题,但我仍然找不到正确的代码。我已经在网上搜索过,我找到了一些关于这个问题的正确答案。这是我用来强制换行的代码
/* break long text without spaces */
word-break: break-all;
word-break: break-word;
hyphens: auto;
我对长文本没问题,上面的代码已经解决了问题.. 但对于普通文本:(虽然单词不是那么长,但它仍然被拆分)
If Mail notifications is check
ed, you will receive notificat
ions about any event that occu
rs on the projects you belong to
**
这是我开始的链接 http://jsfiddle.net/y4Mdy/1802/
对不起,如果我的解释太含糊。 提前感谢所有回复的人:)
最佳答案
此行为是由于 word-break: break-all;
造成的,因为它会打断单词,即使它是连续的并扩展了宽度。所以你可以简单地使用 overflow-wrap: break-word
。
有关此内容的更多信息,请阅读 What is the difference between "word-break: break-all" versus "word-wrap: break-word" in CSS
关于javascript - HTML:如何强制中断长文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35430496/