制作一个<td>跨越表格中的整行 [英] Make a <td> span the entire row in a table

查看:26
本文介绍了制作一个<td>跨越表格中的整行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 HTML 并不陌生,但已经有一段时间没有接触它了,而且我遇到了一个烦人的问题.

I'm not new to HTML but haven't touched it for some good time and I've encountered an annoying problem.

我有一张有两行的表格.
我希望第一行有一个列 - 意味着它将跨越整行,我希望第二行有三列,每列占行宽的 33.3%.

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.

我有这个表的代码:

<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.

如果我给第一行的 宽度值 500px 比方说,它会设置第二行的第一个 代码>到相同的大小.

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.

我做错了什么?

推荐答案

您应该在第一行的 td 上使用 colspan 属性.
Colspan="3" 将单元格设置为流过 3 列.

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>

这篇关于制作一个&lt;td&gt;跨越表格中的整行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆