如何在 bootstrap 4 中使我的桌子高度变小?

sto*_*akt 4 html css html-table bootstrap-4

我怎样才能使我的桌子高度变小?我试过调整<tr>直通 CSS的高度,但它当前使用的高度似乎是它将获得的最小高度。我可以让它更大,但任何低于高度的东西:50px,我没有注意到有什么不同。

这是我的桌子。我只想缩小行高以压缩表格,使其适合屏幕而无需向下滚动。

表格图片

    <table class="table table-striped">
            <thead>
              <tr>
                <th scope="col">Month</th>
                <th scope="col">Overtime Hours</th>
                <th scope="col">Compensation Hours</th>
                <th scope="col">Vacation</th>
                <th scope="col">Personal Hours</th>
                <th scope="col">Sick Hours</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <th scope="row">Carry Over</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">Allotted</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">Starting Total</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">Jan</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">Feb</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">Mar</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">Apr</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">May</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">Jun</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">Jul</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
              </tr>
              <tr>
                <th scope="row">Aug</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
             </tr>
             <tr>
                <th scope="row">Sep</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <th scope="row">Oct</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <th scope="row">Nov</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <th scope="row">Dec</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <th scope="row">Yearly Total</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <th scope="row">Balance in Hours</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <th scope="row">Balance in Days</th>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            </tbody>
 </table>
Run Code Online (Sandbox Code Playgroud)

Fre*_*sar 14

根据 Bootstrap 文档:

您可以简单地table-sm用作表格的补充,通过将单元格填充减半来使表格更加紧凑。它会是这样的:

<table class="table table-striped table-sm">
  <thead>
...
  </thead>
  <tbody>
    <tr>
   ...
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

根据推荐的响应式,您可以.table-responsive{-sm|-md|-lg|-xl}根据需要使用创建响应式表直至特定断点。从该断点开始,表格将正常运行,不会水平滚动。

例子:

<div class="table-responsive-sm">
  <table class="table table-striped">
    ...
  </table>
</div>

<div class="table-responsive-md">
  <table class="table table-striped">
    ...
  </table>
</div>

<div class="table-responsive-lg">
  <table class="table table-striped">
    ...
  </table>
</div>

<div class="table-responsive-xl">
  <table class="table table-striped">
    ...
  </table>
</div>
Run Code Online (Sandbox Code Playgroud)