繁体   English   中英

html表标题行跨到中心标题

[英]html table header rowspan to center headers

我有一个像桌子这样

<table border="1">
<thead>        
    <tr>
        <th colspan="2">Items</th>
        <th colspan="2">Type</th>
        <th colspan="4">Values</th>
        <th colspan="2">Date</th>
    </tr>        
    <tr>
        <th colspan="2"></th>
        <th colspan="2"></th>
        <th colspan="2">Before</th>
        <th colspan="2">After</th>
        <th colspan="2"></th>
    </tr>
</thead>
<tbody></tbody>

在表格的标题中,我想将标题ItemsTypeDate垂直居中。 我尝试在这些标题上使用rowspan="2" ,但这没有用。 有什么想法吗?

使用rowspan ,不必在下一行中添加列(或与rowspan号减一的一样多)。

您的演示已更新

<table border="1">
    <thead>
        <tr>
            <th rowspan="2">Items</th>
            <th rowspan="2">Type</th>
            <th colspan="4">Values</th>
            <th rowspan="2">Date</th>
        </tr>
        <tr>
            <th colspan="2">Before</th>
            <th colspan="2">After</th>
        </tr>
    </thead>
    <tbody></tbody>
</table>

注意:如果删除BeforeAfter colspan ,你的Values colspan可以只是2

<table border="1">
<thead>        
    <tr>
        <th colspan="2" rowspan="2">Items</th>
        <th colspan="2" rowspan="2">Type</th>
        <th colspan="4">Values</th>
        <th colspan="2" rowspan="2">Date</th>
    </tr>        
    <tr>
        <th colspan="2">Before</th>
        <th colspan="2">After</th>
    </tr>
</thead>
<tbody></tbody>
<table border="1">
<thead>        
    <tr>
        <th rowspan="2">Items</th>
        <th rowspan="2">Type</th>
        <th colspan="2">Values</th>
        <th rowspan="2">Date</th>
    </tr>        
    <tr>
        <th>Before</th>
        <th>After</th>
    </tr>
</thead>
<tbody></tbody>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM