为什么内肢不伸展?

时间:2019-09-26 00:12:42

标签: html css

我的桌子有问题。这是我的代码:

<table class="employers__table">
     <thead>
          <tr>
             <td>Таб. №</td>
             <td>Сотрудник / СИЗ</td>
             <td>Разм. ряд</td>
             <td>Кол.</td>
             <td>Ед. изм.</td>
             <td>Дата выдачи</td>
             <td>Дата замены</td>
             <td>Списать СИЗ</td>
             <td>Продлить СИЗ</td>
         </tr>
  </thead>
  <tbody>
        <tbody class="label">
            <tr>
               <td colspan="9">
                   Aaa
               </td>
           </tr>
       </tbody>
 </tbody>
</table>
.employers__table {
    overflow-y: scroll;
}
.label tr > td {
    background-color: #000;
    color: #fff;
}

内部<tbody>不伸展。 This is how it looks

为什么会这样?

我试图在新项目中创建具有相同结构的表,并且该表在那里工作...我不明白。

1 个答案:

答案 0 :(得分:0)

您基本上违反了HTML TABLE的基本语义。

它允许您在<tbody>中有多个table,但不能嵌套tbody

<TABLE>
<THEAD>
     <TR> ...header information...
</THEAD>
<TFOOT>
     <TR> ...footer information...
</TFOOT>
<TBODY>
     <TR> ...first row of block one data...
     <TR> ...second row of block one data...
</TBODY>
<TBODY>
     <TR> ...first row of block two data...
     <TR> ...second row of block two data...
     <TR> ...third row of block two data...
</TBODY>
</TABLE>

正确的代码段

.employers__table {
  overflow-y: scroll;
}

.label tr>td {
  background-color: #000;
  color: #fff;
}
<table class="employers__table">
  <thead>
    <tr>
      <td>Таб. №</td>
      <td>Сотрудник / СИЗ</td>
      <td>Разм. ряд</td>
      <td>Кол.</td>
      <td>Ед. изм.</td>
      <td>Дата выдачи</td>
      <td>Дата замены</td>
      <td>Списать СИЗ</td>
      <td>Продлить СИЗ</td>
    </tr>
  </thead>
  <tbody class="label">
    <tr>
      <td colspan="9">
        Aaa
      </td>
    </tr>
  </tbody>
</table>