【问题标题】:What is an alternative to word-break : break-word; in CSS since it's deprecated and invalid by W3C standards?word-break 的替代方法是什么:break-word;在 CSS 中,因为它已被 W3C 标准弃用且无效?
【发布时间】:2020-05-08 19:27:05
【问题描述】:

我不希望单词被打断,但是如果单词太长,单词可能会被打断。¨

我用word-break: break-word;

但是在验证 CSS 时会报错:不推荐使用 value break-word

我使用了 StackOverflow 中提供的替代方案:

word-break: break-all;  it breaks all words even if the word is not that long-
word-break: normal;
word-break: initial;

word-wrap: break-word;
word-wrap: break-spaces;

overflow-wrap: normal;
overflow-wrap: break-word;

line-break: normal;
line-break: strict;
line-break: anywhere;

但它们都不起作用。他们要么打断所有单词——即使是短词——或者当单词扩展 div-space 时它们不会打断长词。

唯一有效的代码是word-break: break-word;,但已弃用。

word-break: break-word; 的替代品是什么??

【问题讨论】:

    标签: css word-break


    【解决方案1】:

    我遇到了同样的问题,发现 overflow-wrap: anywhere 适合我的情况。信用:https://github.com/w3c/csswg-drafts/issues/2682#issuecomment-438693305

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-17
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-16
    相关资源
    最近更新 更多