Difference between word-wrap: break-word and word-break: break-word

前端 未结 1 1652
盖世英雄少女心
盖世英雄少女心 2020-12-06 17:06

I needed to fix some CSS somewhere because my text wasn\'t wrapping around and was instead going on indefinitely if it was an extremely long word.

Like in most cases

相关标签:
1条回答
  • 2020-12-06 17:54

    Update

    If you plan on breaking words and want to hyphenate as well, try the following:

    .hyphenate {
      overflow-wrap: break-word;
      word-wrap: break-word;
      -webkit-hyphens: auto;
      -ms-hyphens: auto;
      -moz-hyphens: auto;
      hyphens: auto;
    }
    

    This worked even in Chrome ... sort of ... sans hyphens. Anyways a detailed explanation is in this article.


    word-break:break-word is not documented and only master developers know this ultra secret technique like the Quivering Palm of Death.

    Actually it's an obscure -webkit- property that works like word-wrap: break-word but it's also used on dynamic lengths as well.

    Kenneth.io - Word Wrapping Hypernation Using CSS

    CSS-Tricks - word-break

    From CaniUse:

    Chrome, Safari and other WebKit/Blink browsers also support the unofficial break-word value which is treated like word-wrap: break-word.

    0 讨论(0)
提交回复
热议问题