简体   繁体   English

使用 display:table 嵌套表格

[英]Nested tables using display:table

I want to achieve the effect of nested tables using the display:table , display:table-row , display:table -cell .我想使用display:table , display:table-row , display:table -cell来实现嵌套表的效果。

The effect is such that nested table has a width equal to first cell of the main table.效果是嵌套表格的宽度等于主表格的第一个单元格。

See demo: https://jsfiddle.net/bu9mnegr/1/见演示: https : //jsfiddle.net/bu9mnegr/1/

I remember that in table is attribute colspan and nested table has width of all cells of main table.我记得表中的属性是 colspan 并且嵌套表具有主表所有单元格的宽度。 How can I do it without colspan?没有 colspan 怎么办?

try this: note the "with" should be 100% for each "table-col" to span...试试这个:注意“with”应该是 100% 对于每个“table-col”跨越......

<div class="display-table">
    <div>
        <div>cell</div>
        <div>cell</div>
    </div>
    <div>
        <div style="display:block; width:200%;">
            <div class="display-nested-table">
                <div>
                    <div>nested cell</div>
                    <div>nested cell</div>
                </div>
            </div>
        </div>
    </div>
</div>

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

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