Html 固定式可滚动台面

Html 固定式可滚动台面,html,css,html-table,bootstrap-4,Html,Css,Html Table,Bootstrap 4,我必须使用滚动条使这个表格内容(tbody)&表格的高度是固定的。为了启用滚动,我添加了样式display:block。之后,桌子的宽度被冻结,不可调整。给我找个办法把桌子弄满 HTML: <table class="table table-striped table-hover" id="item_table"> <thead> <tr class="bg-primary"> <th>#&l

我必须使用滚动条使这个表格内容(tbody)&表格的高度是固定的。为了启用滚动,我添加了样式
display:block
。之后,桌子的宽度被冻结,不可调整。给我找个办法把桌子弄满

HTML:

   <table class="table table-striped table-hover" id="item_table">
       <thead>
        <tr class="bg-primary">
         <th>#</th>
          <th>Product Name</th>
          <th>Quantity</th>
          <th>Unit Price</th>
          <th>Discount</th>
          <th>Amount</th>
          <th><i class="fa fa-close"></i></th>
         </tr>
   </thead>
   <tbody id="item_list">
     <tr>
       <td>1</td>
       <td>Mens Full Sleeve Shirts</td>
       <td>1</td>
       <td>2200.00</td>
       <td>200.00</td>
       <td>2000.00</td>
       <td><span><i class="fa fa-trash"></i></span></td>
     </tr>
   </tbody>
</table>

不要将
display:block
添加到表中。它将摧毁它

将表Insteed包装到
div
中,并将
overflow:auto
添加到此元素


或者,如果使用引导,请向容器中添加类
表响应
,如您在文档中所看到的不要将
显示:块
添加到表中。它将摧毁它

将表Insteed包装到
div
中,并将
overflow:auto
添加到此元素


或者,如果使用引导,请向容器中添加类
表responsive
,如您在文档中所看到的,请尝试以下操作:

tbody {
    height: 100px;       /* Just for the demo          */
    overflow-y: auto;    /* Trigger vertical scroll    */
    overflow-x: hidden;  /* Hide the horizontal scroll */
}

您好,请尝试以下方法:

tbody {
    height: 100px;       /* Just for the demo          */
    overflow-y: auto;    /* Trigger vertical scroll    */
    overflow-x: hidden;  /* Hide the horizontal scroll */
}

它为整个桌子启用滚动,我只需要为tbody启用滚动。它为整个桌子启用滚动,我只需要为tbody启用滚动。不工作,它设置高度但不启用滚动条。不工作,它设置高度但不启用滚动条。