我在使用HTML colspan
和rowspan
时遇到问题,我想合并第一列(名称)和最后一列(电话),但这给了我不想要的结果。
结果就是我想要的:
这是我得到的:
我的代码:
<table>
<tr>
<th colspan="3">Name</th>
<th rowspan="2">Age</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<th>First name</th>
<th>Middle name</th>
<th>Last name</th>
</tr>
<tr>
<th>pre</th>
<th>post</th>
</tr>
<tr>
<td>Jill</td>
<td>David</td>
<td>Smith</td>
<td>50</td>
<td>055</td>
<td>5778541</td>
</tr>
<tr>
<td>Roben</td>
<td>Jill</td>
<td>Adam</td>
<td>35</td>
<td>050</td>
<td>5577854</td>
</tr>
</table>
答案 0 :(得分:2)
将rowspan
更改为colspan
并确定colspan的值
<table border=1>
<tr>
<th colspan="3">Name</th>
<th colspan="1">Age</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<th>First name</th>
<th>Middle name</th>
<th>Last name</th>
<th></th>
<th>pre</th>
<th>post</th>
</tr>
<tr>
<td>Jill</td>
<td>David</td>
<td>Smith</td>
<td>50</td>
<td>055</td>
<td>5778541</td>
</tr>
<tr>
<td>Roben</td>
<td>Jill</td>
<td>Adam</td>
<td>35</td>
<td>050</td>
<td>5577854</td>
</tr>
</table>
答案 1 :(得分:0)
从第二行开始,您必须填写所有列。
<table>
<tr>
<th colspan="3">Name</th>
<th rowspan="1">Age</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<th>First name</th>
<th>Middle name</th>
<th>Last name</th>
<th></th>
<th>pre</th>
<th>post</th>
</tr>
<tr>
<td>Jill</td>
<td>David</td>
<td>Smith</td>
<td>50</td>
<td>055</td>
<td>5778541</td>
</tr>
<tr>
<td>Roben</td>
<td>Jill</td>
<td>Adam</td>
<td>35</td>
<td>050</td>
<td>5577854</td>
</tr>
</table>
答案 2 :(得分:0)
在前后添加四个空白标题标签 像这样的代码:
<table>
<tr>
<th colspan="3">Name</th>
<th rowspan="2">Age</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<th>First name</th>
<th>Middle name</th>
<th>Last name</th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th>pre</th>
<th>post</th>
</tr>
<tr>
<td>Jill</td>
<td>David</td>
<td>Smith</td>
<td>50</td>
<td>055</td>
<td>5778541</td>
</tr>
<tr>
<td>Roben</td>
<td>Jill</td>
<td>Adam</td>
<td>35</td>
<td>050</td>
<td>5577854</td>
</tr>
</table>