我想让一个表格标题并排集中在两个表格列上。这可能吗?
问问题
58920 次
4 回答
52
<th colspan="2">. This .</th>
稍微推断一下...
<table>
<thead>
<tr>
<th>Single Column</th>
<th colspan="2">Double Column</th>
</tr>
</thead>
<tbody>
<tr>
<td>Column One</td>
<td>Column Two</td>
<td>Column Three</td>
</tr>
</tbody>
</table>
那应该给你足够的工作。
于 2012-01-25T00:43:12.977 回答
8
如果您只有 2 列,那么我建议您使用<caption>
. 否则,请按照其他答案中的建议使用 colspan 。
<table>
<caption>This will span all columns.</caption>
<tr><td>column one</td><td>column two</td></tr>
</table>
于 2012-01-25T00:49:01.957 回答
5
当然。请参阅此页面。您正在寻找colspan
表标题单元格的属性。
于 2012-01-25T00:45:16.113 回答
3
我们可以以更好的方式做到这一点。
<table border="1">
<tr>
<th colspan="1" scope="colgroup">Test Heading</th>
<th colspan="3" scope="colgroup">Mars</th>
<th colspan="3" scope="colgroup">Venus</th>
<th colspan="3" scope="colgroup">Test</th>
</tr>
<tr>
<th rowspan="2"></th>
<th scope="col">Produced</th>
<th scope="col">Sold</th>
<th scope="col">Sold</th>
<th scope="col">Produced</th>
<th scope="col">Sold</th>
<th scope="col">Sold</th>
<th scope="col">Test 1</th>
<th scope="col">Test 2</th>
<th scope="col">Test 3</th>
</tr>
</table>
如果您想了解更多信息,请访问w3.org 的 Table Ref 。
于 2017-05-17T07:12:48.137 回答