制作< td>跨越表中的整个行 [英] Make a <td> span the entire row in a table
问题描述
我对HTML并不陌生,但在一段时间内并没有触及它,而且我遇到了一个令人讨厌的问题。
我有一个两个表行。
我希望第一行有一列 - 意味着它将跨越整行,并且我希望第二行有三列,每行占行宽度的33.3%。 p>
我有这个表的代码:
< table width = 900pxborder =0cellspacing =0cellpadding =0>
< tr>
< td align =center>检查< / td>
< / tr>
< tr>
< td align =center>检查< / td>
< td align =center>检查< / td>
< td align =center>检查< / td>
< / tr>
< / table>
但奇怪的是,第一行有一列与第二行的第一行相同列,每当我改变其中一个,它也会改变另一个。
如果我给第一行的< td>
宽度值 500px
可以说,它将第二行的第一行< td>
设置为相同的尺寸。
我在做什么错?
您应该在第一行的td上使用 colspan
属性。
Colspan =3
将单元格设置为流过3列。
< table width =900pxborder =0cellspacing = 0cellpadding =0>
< tr>
< td align =centercolspan =3>检查< / td>
< / tr>
< tr>
< td align =center>检查< / td>
< td align =center>检查< / td>
< td align =center>检查< / td>
< / tr>
< / table>
I'm not new to HTML but haven't touched it for some good time and I've encountered an annoying problem.
I have a table with two rows.
I want the first row to have one column - means that it will span the entire row, and I want the second row to have three columns, each one 33.3% of the row's width.
I have this code for the table :
<table width="900px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">check</td>
</tr>
<tr>
<td align="center">check</td>
<td align="center">check</td>
<td align="center">check</td>
</tr>
</table>
But what happens is weird, the first row has one column with the same size as the second row's first column, and whenever I change one of them, it changes the other one too.
If I give the first row's <td>
the width value of 500px
lets say, it sets the second row's first <td>
to the same size.
What am I doing wrong ?
You should use the colspan
attribute on the first row's td.
Colspan="3"
will set the cell to flow over 3 columns.
<table width="900px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" colspan="3">check</td>
</tr>
<tr>
<td align="center">check</td>
<td align="center">check</td>
<td align="center">check</td>
</tr>
</table>
这篇关于制作< td>跨越表中的整个行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!