只有当分词在每个字母后突破单词时才会发生溢出。如果用户缩放(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>