如何使子表的列与父表的列具有相同的宽度? [英] How to make the child table's columns have the same width as it's parent table columns?

查看:77
本文介绍了如何使子表的列与父表的列具有相同的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表格内(在td内)有一张表格.

I have a table within a table (inside a td).

此子表的列数与父表的列数完全相同.

This child table has exactly the same number of columns as the parent table.

唯一的问题是,子表的列宽度与父表的列宽度不同.

The only problem is, the child table's columns aren't the same width as the parent table's columns.

它是这样的:

我应该如何设置子表的样式?

How should I style the child table?

是否有预定义的方法来解决此问题?

Is there a predefined way to fix this?

还是我需要通过jquery编写一个归一化"函数来改变页面加载时列的宽度?

Or do I need to write a "normalization" function via jquery which will change the width of columns on page load?

推荐答案

function normaliseWidth(id)
{
    iter = 1;
    $("#splitForm" + id + " td").each(function() {
        //alert($(this)); 
        $(this).width($("#" + id + " td:nth-child(" + iter + ")").width());
        ++iter;
    });
}

我只是遍历所有td并将其宽度更改为父级的宽度.

I just iterated through all the td's and changed their width to parent's width.

这似乎已解决.我希望不会对此有任何副作用.感谢您的所有帮助.

This seems to have fixed it. I'm hoping there won't be any side effects to this. Thanks for all the help.

这篇关于如何使子表的列与父表的列具有相同的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆