简体   繁体   English

HTML Table colspan行跨

[英]HTML Table colspan rowspan

I have 6 columns & I want to use colspan for 3&4 and 5&6 column. 我有6列,我想将colspan用于3&4和5&6列。 And I don't want to show 1st & 2nd column for that particular row. 而且我不想显示该特定行的第一列和第二列。

How to hide 1&2 column in that row? 如何在该行中隐藏1&2列?

Desired output.. 所需的输出

在此处输入图片说明

Remove the border from the cells you wish to "hide". 从要“隐藏”的单元格上删除边框。 They are still there, but visually absent. 他们仍然在那里,但是在视觉上却不在。

Have a fiddle! 小提琴!

Experimental fiddle for a table { border: xxx; } table { border: xxx; } 实验小提琴 table { border: xxx; } table { border: xxx; } fix. table { border: xxx; }修复。

In this example I am targeting the cell with tbody tr:first-child td:first-child . 在此示例中,我使用tbody tr:first-child td:first-child定位单元格。 This could obviously also be targeted with a class . 显然,这也可以针对一个class

HTML HTML

<table>
    <tbody>
        <tr>
            <td colspan="2"></td>
            <td colspan="2"></td>
            <td colspan="2"></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tbody>
</table>

CSS CSS

table {
    border-collapse: collapse;
    width: 500px;
}
td {
    border: solid 1px #000;
    padding: 10px;
}
tbody tr:first-child td:first-child {
    border: none;
}

Use display:none; 使用display:none; in your CSS File on the 1st & 2nd Column. 在第一列和第二列的CSS文件中。

You can select them with: 您可以通过以下方式选择它们:

td:nth-of-type(1),
td:nth-of-type(2) {
   display:none;
}

使用visibility:hidden在该行的前两列中。

Try to use visibility: hidden; empty-cells: hide; 尝试使用visibility: hidden; empty-cells: hide; visibility: hidden; empty-cells: hide; for that cells. 对于那个细胞。

Here is a fiddle 这是一个小提琴

HTML HTML

<table border="1">
    <thead>
        <tr>
            <td colspan="2" style="border: 0;">a1</td>
            <td colspan="2">a3</td>
            <td colspan="2">a5</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>2</td>
            <td>3</td>
            <td>4</td>
            <td>5</td>
            <td>5555</td>
        </tr>
    </tbody>
</table>

CSS CSS

table {
    border: none;
    border-collapse: collapse;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM