如何在table的一个单元格中设置两个单元格?

how to set two cells in one cell of table?

当我想在一个单元格中设置两个单元格时,我感到很困惑 (x, y) CoordLamberts?

.techniques {
  width: 70%;
  border: 1px solid;
}

.techniques,
.techniques th,
.techniques td {
  border-collapse: collapse;
  border: 1px solid;
}
<table class="techniques">
  <tr>
    <th rowspan="2">Foret</th>
    <th rowspan="2">Canton</th>
    <th rowspan="2">Secteur</th>
    <th rowspan="2">Parcelles</th>
    <th>CoordLamberts</th>
    <th rowspan="2">Superficie(ha)</th>
  </tr>
  <tr>
    <th></th>
    <th></th>
    <th></th>
    <th></th>
    <th>x</th>
    <th>y</th>
    <th></th>
  </tr>
  <tr>
    <td>City</td>
    <td>BV</td>
    <td>region</td>
    <td>3</td>
    <td>443</td>
    <td>634</td>
    <td>13</td>
  </tr>
  <tr>
    <td></td>
    <td></td>
    <td></td>
    <td>7</td>
    <td>786</td>
    <td>564</td>
    <td>35</td>
  </tr>
  <tr>
    <td colspan="4">superficie(ha)</td>
    <td>786</td>
    <td>564</td>
    <td>35</td>
  </tr>
</table>
我期望的是: 我得到什么:

.techniques {
  width: 70%;
  border: 1px solid;
}

.techniques,
.techniques th,
.techniques td {
  border-collapse: collapse;
  border: 1px solid;
}
<table class="techniques">
  <tr>
    <th rowspan="2">Foret</th>
    <th rowspan="2">Canton</th>
    <th rowspan="2">Secteur</th>
    <th rowspan="2">Parcelles</th>
    <th colspan="2">CoordLamberts</th>
    <th rowspan="2">Superficie(ha)</th>
  </tr>
  <tr>
    <th>x</th>
    <th>y</th>
  </tr>
  <tr>
    <td>City</td>
    <td>BV</td>
    <td>region</td>
    <td>3</td>
    <td>443</td>
    <td>634</td>
    <td>13</td>
  </tr>
  <tr>
    <td></td>
    <td></td>
    <td></td>
    <td>7</td>
    <td>786</td>
    <td>564</td>
    <td>35</td>
  </tr>
  <tr>
    <td colspan="4">superficie(ha)</td>
    <td>786</td>
    <td>564</td>
    <td>35</td>
  </tr>
</table>

这样。
HTLM table 使用 <thead><tbody><tfoot> ( + <caption> )

.techniques {
  width   : 70%;
  border  : 1px solid;
  }
.techniques,
.techniques th,
.techniques td {
  border-collapse : collapse;
  border          : 1px solid;
  }
.techniques td {
  vertical-align : text-top;
  text-align     : center;
  }
.techniques thead {
  background-color: lightgrey;
  }
.techniques thead th[rowspan="2"]:nth-child(-n+4) {
  min-width: 6em;
  }
.techniques thead th[colspan="2"] {
  min-width: 10em;
  }
.techniques thead th[rowspan="2"]:last-of-type {
  min-width: 10em;
  }
.techniques tfoot {
  background-color: whitesmoke;
  }
<table class="techniques">
  <thead>
    <tr>
      <th rowspan="2">Foret</th>
      <th rowspan="2">Canton</th>
      <th rowspan="2">Secteur</th>
      <th rowspan="2">Parcelles</th>
      <th colspan="2">CoordLamberts</th>
      <th rowspan="2">Superficie(ha)</th>
    </tr>
    <tr>
      <th>X</th>
      <th>Y</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td rowspan="4">City</td>
      <td rowspan="4">BV</td>
      <td rowspan="4">region</td>
      <td>3</td><td>443</td><td>634</td><td>13</td>
    </tr>
    <tr>
      <td>7</td><td>443</td><td>634</td><td>26</td>
    </tr>
    <tr>
      <td>8</td><td>443</td><td>634</td><td>54</td>
    </tr>
    <tr>
      <td>13</td><td>443</td><td>634</td><td>9</td>
    </tr>  
  </tbody>
  <tfoot>
    <tr>
      <td colspan="4">superficie(ha)</td>
      <td colspan="2"></td>
      <td>102</td>
    </tr>
  </tfoot>
</table>

这应该可以工作,但您缺少的是您需要 colspan 而不是 rowspan CoordLamberts 应该使用 2 列,

.techniques{
    width: 70%;
    border: 1px solid;
}
.techniques,.techniques th, .techniques td{
    border-collapse: collapse;
    border: 1px solid;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <table class="techniques">
        <tr>
            <th rowspan="2">Foret </th>
            <th rowspan="2">Canton</th>
            <th rowspan="2">Secteur</th>
            <th rowspan="2">Parcelles</th>
            <th colspan="2">CoordLamberts</th>
            <th rowspan="2">Superficie(ha)</th>
        </tr>
        <tr>
            <td>x</td>
            <td>y</td>
        </tr>
        <tr>
            <td rowspan="4">City</td>
            <td rowspan="4">BV</td>
            <td rowspan="4">region</td>
            <td>3</td>
            <td>395 055</td>
            <td>391 386</td>
            <td>13</td>
        </tr>
        <tr>
            <td>7</td>
            <td>398 981</td>
            <td>398 981</td>
            <td>12</td>
        </tr>
        <tr>
            <td>7</td>
            <td>398 981</td>
            <td>398 981</td>
            <td>12</td>
        </tr>
        <tr>
            <td>7</td>
            <td>398 981</td>
            <td>398 981</td>
            <td>12</td>
        </tr>
        <tr>
            <td colspan="6">Superficie</td>
            <td>102</td>
        </tr>
    </table>
</body>