简体   繁体   English

表列间距不使用colspan占用最后一个空间

[英]Table column spacing take up last space without using colspan

I have a table with four rows. 我有一张四行的桌子。 Inside of row 1 there is 1 column. 在第1行中有1列。 Inside of row 2 there is 3 columns. 第2行内有3列。 Inside of row 3 there is 2 columns. 第3行内有2列。 Inside row 4 there is 2 columns. 在第4行内有2列。 The column of row 1 has a colspan of 3 so that the column spans the whole table but in rows 3 and 4 I want the two columns to spread equally to the full width of the table. 第1行的列的colspan为3,因此该列跨整个表,但是在第3和第4行中,我希望两列均等地散布到表的整个宽度。 The problem is that I cannot add a colspan of 1.5 it just doesn't work. 问题是我无法添加1.5的colspan,但这是行不通的。 My question is how can I get the columns of rows 3 and 4 to span equally across the table in an even matter? 我的问题是,如何均匀地使第3行和第4行的列均匀分布在整个表中?

The code that I have is: 我拥有的代码是:

<table id="tbContainer" style="table-layout:fixed;" cell-padding="0" cell-spacing="0">
<tr>
    <td colspan="3">
        <button style="width: calc(100%);">Button</button>
    </td>
</tr>
<tr>
    <td>
        <button style="width: calc(100%);">Button</button>
    </td>
    <td>
        <button style="width: calc(100%);">Button</button>
    </td>
    <td>
        <button style="width: calc(100%);">Button</button>
    </td>
</tr>
<tr>
    <td colspan="1.5">
        <button style="width: calc(100%);">Button</button>
    </td>
    <td colspan="1.5">
        <button style="width: calc(100%);">Button</button>
    </td>
</tr>
<tr>
    <td colspan="1.5">
        <button style="width: calc(100%);">Button</button>
    </td>
    <td colspan="1.5">
        <button style="width: calc(100%);">Button</button>
    </td>
</tr>

How about a table 12 cells wide. 一张12格宽的桌子怎么样。 12 can be factored by all of the column widths you require. 12可以由所需的所有列宽来决定。

Row 1 colspan 12 - 1 column 第1行colspan 12-1列
Row 2 colspan 4 - 3 columns 第2行colspan 4-3列
Row 3 colspan 6 - 2 columns 第3行colspan 6-2列
Row 4 colspan 6 - 2 columns 第4行colspan 6-2列

<table id="tbContainer" style="table-layout:fixed;" cell-padding="0" cell-spacing="0">
    <tr>
        <td colspan="12">
            <button style="width: calc(100%);">Button</button>
        </td>
    </tr>
    <tr>
        <td colspan="4">
            <button style="width: calc(100%);">Button</button>
        </td>
        <td colspan="4">
            <button style="width: calc(100%);">Button</button>
        </td>
        <td colspan="4">
            <button style="width: calc(100%);">Button</button>
        </td>
    </tr>
    <tr>
        <td colspan="6">
            <button style="width: calc(100%);">Button</button>
        </td>
        <td colspan="6">
            <button style="width: calc(100%);">Button</button>
        </td>
    </tr>
    <tr>
        <td colspan="6">
            <button style="width: calc(100%);">Button</button>
        </td>
        <td colspan="6">
            <button style="width: calc(100%);">Button</button>
        </td>
    </tr>
</table>

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

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