How to wrap long lines without spaces in HTML?

前端 未结 14 1913
旧巷少年郎
旧巷少年郎 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 04:01

    Here's what I do in ASP.NET:

    1. Split the text field on spaces to get all the words
    2. Iterate the words looking for words that are longer than a certain amount
    3. Insert every x characters (e.g. every 25 characters.)

    I looked at other CSS based ways of doing this, but didn't find anything that worked cross-browser.

提交回复
热议问题