Bootstrap 3 table - table-responsive not working

后端 未结 10 1118
攒了一身酷
攒了一身酷 2020-12-30 00:30

I\'m using bootstrap 3 for a website project. I\'m trying to create a page with a responsive table, so that I\'d have the scrollbar when the table is too big. I made a test

相关标签:
10条回答
  • 2020-12-30 01:06

    You can use FooTable. It is a jQuery plugin that allows you to resize and redistribute the data within your tables to best suite your current breakpoint.

    0 讨论(0)
  • 2020-12-30 01:13

    Make sure to set your table display block

    .table {
       display: block !important;
    }
    
    0 讨论(0)
  • 2020-12-30 01:15

    bootstrap's table-responsive works fine in sandbox environments, but it is buggy on live environments. The reason for the bug is that bootstrap gives table-responsive styles of width: 100% and overflow-y: hidden. These two styles do not play nice together. Overflow hiding works best when there is a fixed or max-width. I gave table-responsive a max-width: 270px; for mobile devices, and that fixed the bug.

    0 讨论(0)
  • 2020-12-30 01:16

    I'v done it.

    <div style="display: table">
        <div style="display: table-row">
            <div style="display: table-cell">
    
    
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-xs-12">
    
    
                           //wrapper that will give opportunity to use: overflow-x: auto; 
                           <table style="table-layout: fixed; width: 100%;">
                               <tr>
                                   <td>
    
    
                                      //SCROLL
                                      <div style="width: 100%; overflow-x: auto;">
    
                                          //table, that shoud have "table-responsive" bootstrap class effect
                                          <table class="table table-hover">
    
                                              //...table content...
    
                                          </table>
    
                                      </div>
    
    
                                   <td>
                               </tr>
    
                           </table>                           
    
    
                        </div>
                    </div>
    
            </div>
        </div>
    </div>
    

    You will receive at xs-screen (example from my app):

    0 讨论(0)
  • 2020-12-30 01:17

    I had this problem and found that it worked to either give the table a set width in px, or to set the table to display: block.

    0 讨论(0)
  • 2020-12-30 01:21

    Replace your table-responsive with this

    <div class='table-responsive'> -> <div style="overflow-x:auto;">
    
    0 讨论(0)
提交回复
热议问题