如何让TD标签占据整个空间?

时间:2017-06-28 18:08:59

标签: css

我试图用一个列创建一行占用一行的整个空间,而没有一个列空间:

<table>
    <thead>
        <tr>
            <th>C1</th>
            <th>C2</th>
            <th>C3</th>
            <th>C4</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>L1</td>
            <td>L2</td>
            <td>L3</td>
            <td>L4</td>
        </tr>
        <tr>
            <td>ONE LINE</td> #THIS ONE I WANT TO OCCUPY SPACE OF 4 TDs 
        </tr>
    </tbody>
</table>

我已经尝试过了:

<td style="width:100%">ONE LINE</td>

<tr style="width:100%">
    <td>ONE LINE</td>
</tr>

1 个答案:

答案 0 :(得分:4)

您可以使用colspan attribute

&#13;
&#13;
<table>
    <thead>
        <tr>
            <th>C1</th>
            <th>C2</th>
            <th>C3</th>
            <th>C4</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>L1</td>
            <td>L2</td>
            <td>L3</td>
            <td>L4</td>
        </tr>
        <tr>
            <td colspan="4">ONE LINE</td>
        </tr>
    </tbody>
</table>
&#13;
&#13;
&#13;