Разделите одну головку стола на два ряда - PullRequest
0 голосов
/ 05 ноября 2019

У меня есть одна таблица, в которой один заголовок таблицы должен иметь две строки, а во 2-й строке также должен быть разделен на 4 столбца. короче говоря, одна метка заголовка должна быть разделена на метку 2 строки, а затем 2-ю строку снова на 4 метки.

<table class="table">
                    <thead>
                        <tr>
                            <th>A</th>
                            <th>B</th>
                            <th>C</th>
                            <th>D</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>A value</td>
                            <td>B value</td>
                            <td>C1 C2 C3 C4 value</td>
                            <td>D value</td>
                        </tr>
                    </tbody>
                </table>

Я хочу что-то вроде этого

1 Ответ

0 голосов
/ 05 ноября 2019

Вы можете сделать это следующим образом

<table>
  <col>
  <colgroup span="2"></colgroup>
  <colgroup span="2"></colgroup>
  <tr>
    <td rowspan="2"></td>
    <th colspan="2" scope="colgroup">Mars</th>
    <th colspan="2" scope="colgroup">Venus</th>
  </tr>
  <tr>
    <th scope="col">Produced</th>
    <th scope="col">Sold</th>
    <th scope="col">Produced</th>
    <th scope="col">Sold</th>
  </tr>
  <tr>
    <th scope="row">Teddy Bears</th>
    <td>50,000</td>
    <td>30,000</td>
    <td>100,000</td>
    <td>80,000</td>
  </tr>
  <tr>
    <th scope="row">Board Games</th>
    <td>10,000</td>
    <td>5,000</td>
    <td>12,000</td>
    <td>9,000</td>
  </tr>
</table>

подробнее https://www.w3.org/WAI/tutorials/tables/irregular/

...