可滚动表的不同宽度列

时间:2018-09-13 07:01:29

标签: jquery html css codeigniter scrollable-table

有人可以帮助我吗?我有一个表here is my table,我希望该表可滚动,我在google上搜索,但列为same width here,而我的列为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>

1 个答案:

答案 0 :(得分:0)

使用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