How to break long words in a table td?

后端 未结 4 1019
别跟我提以往
别跟我提以往 2021-02-04 05:12

This is what I have:

4条回答
  •  日久生厌
    2021-02-04 05:56

    I think this solution will help you!

    pre {
        white-space: pre;           /* CSS 2.0 */
        white-space: pre-wrap;      /* CSS 2.1 */
        white-space: pre-line;      /* CSS 3.0 */
        white-space: -pre-wrap;     /* Opera 4-6 */
        white-space: -o-pre-wrap;   /* Opera 7 */
        white-space: -moz-pre-wrap; /* Mozilla */
        white-space: -hp-pre-wrap;  /* HP Printers */
        word-wrap: break-word;      /* IE 5+ */
    }
    

    http://perishablepress.com/press/2010/06/01/wrapping-content/


    // Edit

    It's been a long time since this was accepted as the best answer and updates are required. See @benhowdle89's and @Steve's answers below.

    So the current browser support is now good enough to use word-break in order to allow words to be broken over multiple lines.

    word-break: break-all

    http://caniuse.com/#feat=word-break

提交回复
热议问题