当断字在每个字母后打破一个单词时会发生溢出

时间:2018-02-05 19:24:50

标签: javascript jquery html css overflow

只有当分词在每个字母后突破单词时才会发生溢出。如果用户缩放(CMD +)非常大,就会发生这种效果。

CSS:

.turnOnWordBreak {
    overflow-wrap: break-word;
    word-wrap:     break-word;

    width:         auto;

    white-space:   normal;
}

.turnOffWordBreak {
    overflow-wrap: normal;
    word-wrap:     normal;

    width:         auto;
}

JS:

/* turn on/off word break */

wordBreakOn = (function turnOnWordBreak() {

    /*
        .superLongStuff is empty ...
        .turnOnWordBreak and .turnOffWordBreak do all the work
    */
    $('.superLongStuff').removeClass('turnOffWordBreak').addClass('turnOnWordBreak');

})


wordBreakOff = (function turnOffWordBreak() {

    $('.superLongStuff').removeClass('turnOnWordBreak').addClass('turnOffWordBreak');

})

$(document).ready(function() {

    wordBreakOn();
});

HTML:

<div class="superLongStuff">
lots and lots of long text
</div>

0 个答案:

没有答案