首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将一个表头分成两行

问将一个表头分成两行
EN

Stack Overflow用户
提问于 2019-11-05 13:52:42
回答 1查看 466关注 0票数 0

我有一个表,其中一个表头必须有两行,在第二行也必须分为4列。简而言之,一个头标签必须被分成2行标签,然后第二行又被分成4个子标签。

代码语言:javascript
复制
<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>

I want something like this

EN

回答 1

Stack Overflow用户

发布于 2019-11-05 13:54:31

你可以这样做

代码语言:javascript
复制
<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>

more info https://www.w3.org/WAI/tutorials/tables/irregular/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58705246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档