use*_*368 1 html css html-table
我有一个像桌子这样:
<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>
Run Code Online (Sandbox Code Playgroud)
在表格的标题中,我想要标题Items,Type并Date垂直居中.我尝试使用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>
Run Code Online (Sandbox Code Playgroud)
注意:如果删除Before和After colspan,你Values colspan可以只是2.