如何垂直对齐标签中的项目?

How to align vertically items in th tag?

我有一个这样的table table image

如何将所有文本位置设置为文本框的中心

这是我的代码

<table id="zero_config" class="table table-striped table-bordered dataTable"
                                       role="grid" aria-describedby="zero_config_info" style=" table-layout: fixed ;">
                                    <thead>
                                    <tr >
                                        <th rowspan="2" style="text-align: center;padding-top: 0px;">Theo ngày</th>
                                        <th rowspan="2" style="text-align: center;padding-top: 0px;">Tên đối tác</th>
                                        <th colspan="2" style="text-align: center" >Giao dịch cũ - Đã khớp</th>
                                        <th colspan="2" style="text-align: center" >Giao dịch mới đã khớp tự động</th>
                                        <th colspan="2" style="text-align: center" >Giao dịch mới- Lệnh tự động, khớp nhân công</th>
                                        <th colspan="2" style="text-align: center" >Giao dịch mới - Chưa khớp</th>
                                    </tr>
                                    <tr >
                                        <th style="text-align: center">Số lượng GD</th>
                                        <th style="text-align: center">Số gạch nợ (đã có VAT) </th>
                                        <th style="text-align: center">Số lượng GD</th>
                                        <th style="text-align: center">Số gạch nợ (đã có VAT)</th>
                                        <th class="text-center" style="text-align: center;">>Số lượng GD</th>
                                        <th style="text-align: center">Số gạch nợ (đã có VAT)</th>
                                        <th style="text-align: center">Số lượng GD </th>
                                        <th style="text-align: center">Số gạch nợ (đã có VAT)</th>

                                    </tr>

                                    </thead>
                                    <tbody>

我刚加

<style type="text/css">
    table, thead, tr, th {
        display: flex-box;
        border: 1px solid black;
    }

    th {
        height: 100px;
        width: 100px;
    }
</style>

到您提供的 html 代码,一切都水平、垂直居中。只要了解如何正确使用flex-box,您应该能够实现您想要的布局。

根据我的理解,您只需将 vertical-align: middle 添加到 table。如果不是,请详细说明您的问题

.table thead th {
  vertical-align: middle !important;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<table id="zero_config" class="table table-striped table-bordered dataTable" role="grid" aria-describedby="zero_config_info" style=" table-layout: fixed ;">
  <thead>
    <tr>
      <th rowspan="2" style="text-align: center;padding-top: 0px;">Theo ngày</th>
      <th rowspan="2" style="text-align: center;padding-top: 0px;">Tên đối tác</th>
      <th colspan="2" style="text-align: center">Giao dịch cũ - Đã khớp</th>
      <th colspan="2" style="text-align: center">Giao dịch mới đã khớp tự động</th>
      <th colspan="2" style="text-align: center">Giao dịch mới- Lệnh tự động, khớp nhân công</th>
      <th colspan="2" style="text-align: center">Giao dịch mới - Chưa khớp</th>
    </tr>
    <tr>
      <th style="text-align: center">Số lượng GD</th>
      <th style="text-align: center">Số gạch nợ (đã có VAT) </th>
      <th style="text-align: center">Số lượng GD</th>
      <th style="text-align: center">Số gạch nợ (đã có VAT)</th>
      <th class="text-center" style="text-align: center;">>Số lượng GD</th>
      <th style="text-align: center">Số gạch nợ (đã có VAT)</th>
      <th style="text-align: center">Số lượng GD </th>
      <th style="text-align: center">Số gạch nợ (đã có VAT)</th>

    </tr>

  </thead>
  <tbody>

看来您正在使用引导程序。尝试添加到元素:

class="align-middle"text-center

喜欢:

   <th class="align-middle text-center" rowspan="2">Theo ngày</th>