使用自定义字体在下一行强制使用长单词

Forcing the long word in the next line using custom font

本文关键字:一行 单词 字体 自定义      更新时间:2023-09-26

我正在使用word-wrap将长单词分解到下一行,但它不工作。这是我的JsFiddle代码。

基本上我的div是动态生成的。这就是我正在做的

Reading the div value.
Adding word-wrap property in all the child divs
Adding a Custom Font
Auto Resizing the text to fill in the div.

我添加了像这样的换行符

//adding the word-wrap property
var target = $("#" + element);
target.find('*').each(function() {
    $(this).css('display', 'inline-block');
    $(this).css('word-break', 'break-word');
    $(this).css('word-break', 'break-all');
});

但是结果并没有强制把单词放到下一行。检查我的JsFiddle。我该怎么做才能把这个单词强制放到下一行呢?

css: word-wrap,不同于css: word-break。前者可设置为break-word,后者可设置为break-all。您连续设置了两次断行,覆盖了第一个设置,这不是一个真正的设置,因为它对word-break无效。我猜你是想用word-wrap