Bootstrap tables overflowing with long unspaced text

前端 未结 5 1201
谎友^
谎友^ 2020-12-23 12:56

I\'m using Bootstrap and I have a table with a few columns, the last of which sometimes has a long piece of text without spaces. I noticed that under certain screen sizes, t

相关标签:
5条回答
  • 2020-12-23 13:34

    I was having trouble with these solutions working in Internet Explorer.

    I used the following style to get it to finally work.

    <td style="word-break: break-all">
    
    0 讨论(0)
  • 2020-12-23 13:35
    .the-table {
        table-layout: fixed;
        word-wrap: break-word;
    }
    

    Deprecated (i.e. word-wrap)

    Add the following styles to your <table>

    .the-table {
        table-layout: fixed;
        over-flow: break-word;
    }
    

    Then you can adjust your layout via-CSS as you wish.

    0 讨论(0)
  • 2020-12-23 13:42

    You can use below css. This will wrap the text and apply ... in the end of the text.

    e.g. This_is_a_large_text will be changed to This_is_a_lar...

    td {
      max-width: 120px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    

    You can also add tool tip to show the complete text value.

    <td data-toggle="tooltip" title="${text}">${text}</td>
    
    0 讨论(0)
  • 2020-12-23 13:53

    Albers answer did the trick for me

    .the-table {
     table-layout: fixed;
     word-wrap: break-word;
    }
    

    In the JS to load it dynamically add

     $("#"  + tableName ).addClass('the-table'); 
    

    Hope it helps!!

    0 讨论(0)
  • 2020-12-23 13:58

    This works without forcing table layout to be fixed Just add it to td or any

    .is-breakable {
      word-break: break-word;
    }
    
    0 讨论(0)
提交回复
热议问题