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

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

问题描述



这个子表的列与父表的列数完全相同。

所以,我在表内有一个表()。 p>

唯一的问题是,子表的列与父表的列不一样宽。



它是这样的:





我应该如何设计子表格?



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

或者我需要通过jquery写一个规范化函数,它会改变页面加载时的列宽?

{
iter = 1;解决方案


$(#splitForm+ id +td)。each(function(){
// alert($(this));
$(this).width($ (#+ id +td:nth-​​child(+ iter +)).width());
++ iter;
});
}

我只是遍历所有的td,并将​​其宽度更改为父宽度。 / p>

这似乎修复了它。我希望不会有任何副作用。感谢您的帮助。


So, 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.

This is how it looks like:

How should I style the child table?

Is there a predefined way to fix this?

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;
    });
}

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.

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

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