Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在html表格的列中添加单元格?_Html_Html Table - Fatal编程技术网

如何在html表格的列中添加单元格?

如何在html表格的列中添加单元格?,html,html-table,Html,Html Table,我很难找到将单元格添加到列中的正确方法:下面是我要做的: 你从以下地方得到的小提琴: fasfg1 fasfg2 我会在左侧行中再制作一个表,并将行添加到新表中我会在左侧行中再制作一个表,并将行添加到新表中尝试此操作,使用rowspan <!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="t

我很难找到将单元格添加到列中的正确方法:下面是我要做的:

你从以下地方得到的小提琴:


fasfg1
fasfg2

我会在左侧行中再制作一个表,并将行添加到新表中

我会在左侧行中再制作一个表,并将行添加到新表中

尝试此操作,使用rowspan

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
    <table style="margin-top: 40px" width="600" height="358" cellspacing="0" cellpadding="2" align="center"  border="1">
                    <tr>
                        <td align="center">fasfg1
                        </td>
                        <td  width="42" rowspan="3"></td>
                         <td align="center" rowspan="3">fasfg2
                        </td>
                    </tr>
                    <tr>
                        <td>zroizj</td>
                    </tr>
                    <tr>
                        <td>zroizj</td>
                    </tr>
                </table>
</body>
</html>

fasfg1
fasfg2
zroizj
zroizj

请注意,如果将来要在左列中添加更多行,那么维护此代码可能非常困难。最好使用两个不同的表。

用rowspan试试这个

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
    <table style="margin-top: 40px" width="600" height="358" cellspacing="0" cellpadding="2" align="center"  border="1">
                    <tr>
                        <td align="center">fasfg1
                        </td>
                        <td  width="42" rowspan="3"></td>
                         <td align="center" rowspan="3">fasfg2
                        </td>
                    </tr>
                    <tr>
                        <td>zroizj</td>
                    </tr>
                    <tr>
                        <td>zroizj</td>
                    </tr>
                </table>
</body>
</html>

fasfg1
fasfg2
zroizj
zroizj

请注意,如果将来要在左列中添加更多行,那么维护此代码可能非常困难。最好使用两个不同的表。

这不是一个很好的方法,但如果在一个表中执行,则每个单元格需要单独的行,其余项目需要单独的行。要使另一侧的大小相同,必须使用rowspan。添加列时,需要将rowspan更新1,并根据要插入的特定大小新建一个列,并将其从上一个列指定的高度删除

更好的方法是为每个波段使用单独的表格或表格中的表格

<!DOCTYPE html>
    <html>
        <head>
            <title></title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        </head>
        <body>
            <table style="margin-top: 40px" width="600" height="358" cellspacing="0" cellpadding="2" align="center"  border="1">
                            <tr style="height:10px">
                                <td align="center">fasfg1</td>
                                <td width="42" rowspan="4"></td>
                                <td align="center" rowspan="4">fasfg2
                                </td>
                            </tr>
                            <tr style="height:10px">
                                <td align="center" height="5%">fasfg1</td>
                            </tr>
                            <tr style="height:10px">
                                <td align="center" height="5%">fasfg1</td>
                            </tr>
                            <tr style="height:100px">
                                <td align="center">fasfg1</td>
                            </tr>    
                        </table>
        </body>
    </html>​

fasfg1
fasfg2
fasfg1
fasfg1
fasfg1
​

这不是一个很好的方法,但是如果在一个表中执行,那么每个单元格需要单独的行,其余的项目需要单独的行。要使另一侧的大小相同,必须使用rowspan。添加列时,需要将rowspan更新1,并根据要插入的特定大小新建一个列,并将其从上一个列指定的高度删除

更好的方法是为每个波段使用单独的表格或表格中的表格

<!DOCTYPE html>
    <html>
        <head>
            <title></title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        </head>
        <body>
            <table style="margin-top: 40px" width="600" height="358" cellspacing="0" cellpadding="2" align="center"  border="1">
                            <tr style="height:10px">
                                <td align="center">fasfg1</td>
                                <td width="42" rowspan="4"></td>
                                <td align="center" rowspan="4">fasfg2
                                </td>
                            </tr>
                            <tr style="height:10px">
                                <td align="center" height="5%">fasfg1</td>
                            </tr>
                            <tr style="height:10px">
                                <td align="center" height="5%">fasfg1</td>
                            </tr>
                            <tr style="height:100px">
                                <td align="center">fasfg1</td>
                            </tr>    
                        </table>
        </body>
    </html>​

fasfg1
fasfg2
fasfg1
fasfg1
fasfg1
​

这是表格数据吗?如果是,那么为什么不使用单元格和
rowspan
来获得这种效果呢?如果您使用表格进行网站布局,我建议您重新考虑并使用语义标记。@MoinZaman您好,谢谢您的评论。。。我绝不会用这种方式建立网站-P不,这是针对html电子邮件和所有电子邮件客户端的错误性质…html表格是处理漂亮电子邮件的方式。iMx建议在第一个单元格中使用另一个表格,这绝对是一个选项。这是表格数据吗?如果是,那么为什么不使用单元格和
rowspan
来获得这种效果呢?如果您使用表格进行网站布局,我建议您重新考虑并使用语义标记。@MoinZaman您好,谢谢您的评论。。。我绝不会用这种方式建立网站-P不,这是针对html电子邮件和所有电子邮件客户端的错误性质…html表格是处理漂亮电子邮件的方式。iMx建议在第一个单元格中使用另一个表,这绝对是一种选择。