Why doesn't break word work on a long string with commas?

前端 未结 3 1325
广开言路
广开言路 2020-12-17 17:13

I have a long comma delimited string and I\'m trying to use the css style word-wrap:break word but it doesn\'t seem to work on a string without spaces. Is this expected?

3条回答
  •  醉梦人生
    2020-12-17 17:56

    word-wrap:break-word; is still experimental, so different browsers might support it or not.

    If you have can, insert a zero-width space after the commas. It's U+200B in Unicode, or in HTML. The browser will break the string up at the zero-width space as it needs to. You can probably do that in whatever code is producing the HTML, or write some javascript to automatically insert the character.

    See also Wikipedia.

提交回复
热议问题