CSS中更智能的词分词? [英] Smarter word break in CSS?
问题描述
如果我只是在元素上放置 word-break:break-all
,我通常会得到结果:
If I just put word-break: break-all
on an element, I often end up with this:
您好,我要输入一个太长的
sage。
Hello people, I am typing a mes
sage that's too long to fit!
显然,这会好得多:
你好人,我在打字
Hello people, I am typing a
message that's too long to fit!
但同时如果有人写:
BLAAAAAAAAARRRRRRRRRRRRGGGGGGGGHHHHHHHH !!!!!!
BLAAAAAAAAARRRRRRRRRRRRGGGGGGGGHHHHHHHH!!!!!!
那么我想要的是: / p>
Then I'd want it to be:
BLAAAAAAAAARRRRRRRRRRR
RGGGGGGGGHHHHHHHH !!!!!!
BLAAAAAAAAARRRRRRRRRRR
RGGGGGGGGHHHHHHHH!!!!!!
我似乎找不到一种方法来实现这一点。
I can't seem to find a way to actually do this.
请注意,元素的宽度不是固定的,
Note that the width of the element is not fixed and may change.
推荐答案
尝试 word-wrap:break-word;
应该按照你的期望行事。
Try word-wrap: break-word;
it should behave as you expect.
这篇关于CSS中更智能的词分词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!