How to force breaking of non breakable strings?

后端 未结 9 1062
-上瘾入骨i
-上瘾入骨i 2021-02-04 18:52

I have an HTML page that I generate from the data contained in a database. The database sometimes contains long strings that the browser can\'t break because the strings don\'t

9条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-04 19:27

    Yes you can, just set the css property of the box to:

    .some_selector {
        word-wrap: break-word;
    }
    

    Edit: Some testing shows that it does work with a div or a p - a block level element - but it does not work with a table cell, nor when the div is put inside a table cell.

    Tested and works in IE6, IE7, IE8, Firefox 3.5.3 and Chrome.

    Works:

    aaaaaaaaaaaaaaaaaaaaaaffffdffffdffffdffffdffffdffffdffffdffffdffffdffffdffffdffffdffffdffffdaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

提交回复
热议问题