表两个表的列宽必须相同

表两个表的列宽必须相同

本文介绍了表两个表的列宽必须相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个表格,宽度为600px,每列有5列。但是,尚未为每个列设置宽度。这里,我想让列宽在两个表中必须相同。你可以使用CSS或jQuery。



pre> < table width =600border =1cellspacing =0cellpadding =0>
< tr>
< td> hdng 1< / td>
< td> hdng 2< / td>
< td> hdng 3< / td>
< td> hdng 4< / td>
< td> hdng 5< / td>
< / tr>
< / table>
< table width =600border =1cellspacing =0cellpadding =0>
< tr>
< td>内容内容内容< / td>
< td> con< / td>
< td>内容内容内容< / td>
< td>内容内容内容< / td>
< td>内容内容内容< / td>
< / tr>
< / table>

任何帮助将非常感激。

解决方案

如果您希望所有列的宽度相同,并且确定每个表格中正好有五列,我建议:

 < table style =table-layout:fixed> 
< col style =width:20%span =5/>
< tr><! - stuffs ...->< / tr>
< / table>


There are two tables with width 600px and 5 Columns each. But, width has not been set for each column. Here, I want to make columns width must be same in both the tables. You can use CSS or jQuery. And, I dont want to fix the column width manually.

HTML Example:

<table width="600" border="1" cellspacing="0" cellpadding="0">
    <tr>
        <td>hdng 1</td>
        <td>hdng 2</td>
        <td>hdng 3</td>
        <td>hdng 4</td>
        <td>hdng 5</td>
    </tr>
</table>
<table width="600" border="1" cellspacing="0" cellpadding="0">
    <tr>
        <td>content content content</td>
        <td>con</td>
        <td>content content content</td>
        <td>content content content</td>
        <td>content content content</td>
    </tr>
</table>

Any help would be highly appreciated.

解决方案

If you want all columns are in the same width, and since you're sure that you'll have exactly five columns in each table, I would suggest:

<table style="table-layout:fixed">
<col style="width:20%" span="5" />
<tr><!--stuffs...--></tr>
</table>

这篇关于表两个表的列宽必须相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 06:41