0

任何人都可以帮助我吗?我有一张桌子,这是我的桌子,我希望这张桌子可以滚动,我在谷歌上搜索,但该栏same width 在这里,我的栏在这里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>
4

1 回答 1

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%;
}

演示

于 2018-09-13T07:02:39.293 回答