【问题标题】:Match the row height of parent and child table cells匹配父子表格单元格的行高
【发布时间】:2014-09-29 04:09:47
【问题描述】:

我在表内有一个子表。有用于插入新表的行跨度。

现在我的问题是当主表格单元格的内容增加时,相应单元格的子行也应该得到扩展。

这是表结构

<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>Col 1</td>
            <td>Col 2</td>
            <td rowspan="3">
              <table border="0" class="child_table" cellspacing="0" cellpadding="0">
                <tr>
                  <td>Sub col 1</td>
                  <td>Sub col 2</td>
                </tr>
                <tr>
                  <td>Sub col 1</td>
                  <td>Sub col 2</td>
                </tr>
              </table>
            </td>
            <td>Col 4</td>
   </tr>
       <tr>
            <td>Col 1</td>
            <td>Col 2</td>
            <td>When the content of this cell increases I want the 2nd (respective) row of child table also to extend accordingly.</td>
   </tr>
        <tr>
            <td>Col 1</td>
            <td>Col 2</td>
            <td>Col 4</td>
   </tr>
  </table>

FIDDLE

【问题讨论】:

  • 你能解释一下为什么不能只用一张桌子吗?
  • 因为默认情况下子表应该处于折叠模式。要应用该展开/折叠效果,我需要将这些单元格放在不同的部分,以便在其中放置新表。
  • 你能把折叠行为添加到小提琴吗?
  • 给你jsbin.com/nemajoru/3 默认情况下是这样的
  • 是否可以将子表的每一行分开并添加父行作为子表

标签: javascript jquery css html-table


【解决方案1】:

jsBin demo

table{
  background:#C2E5FF;
  position:relative;
    height:100%;  /* Set 100% height */
}
td{
  border:1px solid #ccc;
  vertical-align:top;
  width:20%
                  /* Don't use height */
}
.child_table{
  background:#FFFFCA;
    width:100%;  /* Set width to 100% */
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-21
    • 2023-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多