How to wrap long lines without spaces in HTML?

前端 未结 14 1938
旧巷少年郎
旧巷少年郎 2020-12-01 03:28

If a user types in a long line without any spaces or white space, it will break formating by going wider than the current element. Something like:

HA

14条回答
  •  余生分开走
    2020-12-01 03:57

    Add the Zero width space () to the string and it will wrap.

    Here is a Javacript example:

    let longWordWithOutSpace = 'pneumonoultramicroscopicsilicovolcanoconiosis';
    // add ​ between every character to make it wrap
    longWordWithOutSpace.split('').join('​');
    

提交回复
热议问题