【问题标题】:Scrollable table different width column可滚动表格不同宽度列
【发布时间】:2018-09-13 07:01:29
【问题描述】:

任何人都可以帮助我吗?我有一个表here is my table,我希望这个表可以滚动,我在谷歌上搜索,但列是same widthhere,这里我的列是different width

这是我的专栏正在改变大小,因为这是我的风格

.scrollTable thead {
display: block;}

.scrollTable tbody {
display: block;
height: 320px;
overflow: auto;}

这是我的 HTML 代码

  <table class="scrollTable" width="100%" >
         <thead>
            <tr id="notclickable">
               <th width="3%" class="table-conf header-table">Order No. </th>
               <th width="10%" class="table-conf header-table">Latest No</th>
               <th width="20%" class="table-conf header-table">Parts Name</th>
               <th width="7%" class="table-conf header-table">Qty</th>
               <th width="8%" class="table-conf header-table">Unit Price</th>
               <th width="10%" class="table-conf header-table">Amount</th>
            </tr>
          </thead>
          <tbody>
              <?php 
                   for ($i=0; $i < 15; $i++) :
               ?>                          
            <tr>
               <td class="table-conf <?= ($i % 2 == 0 ) ? "even" : "odd" ; ?>"><br>ganteng</td>
               <td class="table-conf <?= ($i % 2 == 0 ) ? "even" : "odd" ; ?>"><br>ganteng</td>
               <td class="table-conf <?= ($i % 2 == 0 ) ? "even" : "odd" ; ?>"><br>ganteng</td>
               <td class="table-conf <?= ($i % 2 == 0 ) ? "even" : "odd" ; ?>"><br>ganteng</td>
               <td class="table-conf <?= ($i % 2 == 0 ) ? "even" : "odd" ; ?>"><br>ganteng</td>
               <td class="table-conf <?= ($i % 2 == 0 ) ? "even" : "odd" ; ?>"><br>ganteng</td>
            </tr>
                <?php endfor; ?>
         <!-- //sek2 engkok lek bingung tak takok kon maneh iki takcobak plek karo ndk conto -->
         </tbody>
    </table>

【问题讨论】:

标签: jquery html css codeigniter scrollable-table


【解决方案1】:

使用width:100%table-layout:fixed; 喜欢,

.scrollTable thead {
    display: block;
}
.scrollTable tbody tr {
    table-layout:fixed;
    display:table;
    width:100%;
}
.scrollTable tbody {
    display:block;
    height:50px;
    overflow:auto;
    width:100%;
}

Demo

【讨论】:

  • 我认为是因为display:block
  • 是的,将tabletable-* 元素视为block 元素是不好的。
  • 因为,没有 display:block 我们无法制作可滚动的 body ,试试看我的小提琴 plz jsfiddle.net/nmzvef80/1
  • 解决了兄弟,我使用了来自 bootstrap 的 table-responsive 类,我在那里使用了 3 张桌子,thead 的桌子,tbody 的桌子和 tfoot LoL 的桌子,现在它工作正常,谢谢你们回答我的问题问题^_^
猜你喜欢
  • 2018-08-14
  • 1970-01-01
  • 2013-07-06
  • 1970-01-01
  • 2017-03-02
  • 2011-06-13
  • 2015-03-11
  • 1970-01-01
  • 2011-05-18
相关资源
最近更新 更多