Cause line to wrap to new line after 100 characters

前端 未结 7 1587
慢半拍i
慢半拍i 2020-12-14 08:23

Is there a way in CSS that I can cause the 3rd element in this list, which is longer than the rest, to wrap to a new line if it extends over 100 characters? so that the rest

相关标签:
7条回答
  • 2020-12-14 08:48

    Please try this code. I have successfully implemented word-wrapping using Javascript.

    var a = $('.targetDiv').text().match(/.{1,50}/g);
    var b = '';
    if (a != null) {
        for (var i = 0; i< a.length; i++) {
            if (a[i].toString() != null) {
                b = b + '<p>' + a[i].toString() + '</p>';
            }
        }
        $('.targetDiv').html(b);
    }
    
    0 讨论(0)
提交回复
热议问题