jQuery DataTable overflow and text-wrapping issues

后端 未结 10 1592
遇见更好的自我
遇见更好的自我 2020-12-07 18:42

I have the following DataTable (full-width css class sets width = 100%)

LOB&
相关标签:
10条回答
  • 2020-12-07 19:15

    The same problem and I solved putting the table between the code

    <div class = "table-responsive"> </ div>
    
    0 讨论(0)
  • 2020-12-07 19:19

    You can just use render and wrap your own div or span around it. TD`s are hard to style when it comes to max-width, max-height, etc. Div and span is easy..

    See: https://datatables.net/examples/advanced_init/column_render.html

    I think a nicer solution then working with CSS hacks which are not supported cross browser.

    0 讨论(0)
  • 2020-12-07 19:20

    Just simply the css style using white-space:nowrap works very well to avoid text wrapping in cells. And ofcourse you can use the text-overflow:ellipsis and overflow:hidden for truncating text with ellipsis effect.

    <td style="white-space:nowrap">Cell Value</td>
    
    0 讨论(0)
  • 2020-12-07 19:26

    The following CSS declaration works for me:

    .td-limit {
        max-width: 70px;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
    }
    
    0 讨论(0)
  • 2020-12-07 19:27

    I faced the same problem of text wrapping, solved it by changing the css of table class in DT_bootstrap.css. I introduced last two css lines table-layout and word-break.

       table.table {
        clear: both;
        margin-bottom: 6px !important;
        max-width: none !important;
        table-layout: fixed;
        word-break: break-all;
       } 
    
    0 讨论(0)
  • 2020-12-07 19:28

    Using the classes "responsive nowrap" on the table element should do the trick.

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