word-wrap:break-word和word-break:break-all的区别

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了word-wrap:break-word和word-break:break-all的区别相关的知识,希望对你有一定的参考价值。

  当我们要显示的句子“how are youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”超过了容器的宽度(且容器宽度大于"how are"显示的宽度)时,

  若我们使用了word-wrap:break-word,则“how are”的位置不变,而“youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”会跳到下一行,要是“youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”还超出容器的宽度,则此单词会被拆开到下一行显示;

  若我们使用了word-break:break-all;则会根据容器的宽度显示此句子,直接从长单词“youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”的某部位拆开此单词,后面部分显示到下一行。即,长单词“youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”会根据容器宽度去让单词断开,断开的前部分会跟“how are”显示在同一行,断开的后部分显示到下一行。

  同样的是word-wrap:break-word和word-break:break-all都可以让超过容器宽度的单词被拆分开来。

以上是关于word-wrap:break-word和word-break:break-all的区别的主要内容,如果未能解决你的问题,请参考以下文章

文字在边界自动换行word-wrap:break-word

word-wrap: break-word;和word-break: break-all;的区别

word-wrap:break-word 在 IE8 中不起作用

CSS中的“word-break:break-all”与“word-wrap:break-word”有啥区别

word-wrap:break-word;和word-break:break-all;的区别

我可以将 word-wrap:break-word 设置为提交类型的输入吗?