简体   繁体   English

如何在CSS中堆叠表格的一行的TD元素?

[英]How to stack up TD elements of just one ROW of a table in CSS?

Ideally I would use divs, but it is not an option.理想情况下,我会使用 div,但这不是一种选择。

I need too stack up or pile up TD inside one row of a table, while leaving the rest as it is.我也需要在桌子的一排内堆叠或堆积 TD,而其余部分保持原样。

With display: block;带显示:块; it kind of works, except then all the TD stack up are only the width of one column.它有点工作,除了所有 TD 叠加只是一列的宽度。 (see code) (见代码)

Is there a way to, in css, stack up TD and make them 100% of the row?有没有办法在 css 中堆叠 TD 并使它们占行的 100%?

Many thanks in advance!提前谢谢了!

 .red { border: solid red 0.25em ; display: block; } .blue { border: solid blue 0.25em ; display: block; } td { border: solid grey 0.25em ; }
 <table> <tr> <td>top row</td> <td>top row</td> <td>top row</td> </tr> <tr> <td class="blue" > needs to go on top of the other td</td> <td class="red" > </td> <td class="red"> </td> </tr> </table>

I don't know if it's what yuo need.不知道是不是你需要的But, if you need a tr on top of a table, you can usethead like below但是,如果您需要在表格顶部使用 tr,您可以使用如下所示的thead

<table>
    <caption>Council budget (in £) 2018</caption>
    <tbody>
        <tr>
            <th scope="row">Donuts</th>
            <td>3,000</td>
        </tr>
        <tr>
            <th scope="row">Stationery</th>
            <td>18,000</td>
        </tr>
    </tbody>
    <thead>
        <tr>
            <th scope="col">Items</th>
            <th scope="col">Expenditure</th>
        </tr>
    </thead>
</table>

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

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