2011-09-15 116 views
0

我试图做一个简单的表,但有一次我在连续的表格行设置colspans,第二行的colspan属性都将被覆盖:嵌套合并单元格

<table class="d-week"> 
<caption> 
<h4>table</h4> 
</caption> 
<thead> 
    <tr> 
     <th class="col_first"></th> 
     <th colspan="1">1st week</th> 
     <th colspan="1">2nd week</th> 
     <th colspan="1">3rd week</th> 
    </tr> 
    <tr> 
     <th></th> 
     <th colspan="3">prop1</th> 
     <th colspan="3">prop2</th> 
     <th colspan="3">prop3</th> 
    </tr> 
</thead> 
<tbody> 
    <tr> 
     <td></td> 
     <td>col1</td> 
     <td>col1</td> 
     <td>col1</td> 
     <td>col2</td> 
     <td>col2</td> 
     <td>col2</td> 
     <td>col3</td> 
     <td>col3</td> 
     <td>col3</td> 
    </tr> 
</tbody> 
</table> 

但在这里,表体细胞与第一行的标题对齐,而不是第二行(即使我从第一个标题的行中删除colspan属性)。有人能帮助我吗?

编辑:如果在第二个标题的行中有多于3个th会怎么样? http://jsbin.com/icetom/3

+0

Cal你也给一个简单的例子你期望什么? – Nivas

回答

2

我don'tknow如果我理解不错,但是,也许你只需要设置列跨度= 3头的第一行。您可以考虑相对于您将拥有的最大单元数的calspan。在你的例子中,它是10.如果你想要一行中的一个列跨越多个列,你可以根据它选择数字。

2
<table> 
<caption> 
<h4>table</h4> 
</caption> 
<thead> 
    <tr> 
     <th></th> 
     <th colspan="3">1st week</th> 
     <th colspan="3">2nd week</th> 
     <th colspan="3">3rd week</th> 
    </tr> 
    <tr> 
     <th></th> 
     <th colspan="3">prop1</th> 
     <th colspan="3">prop2</th> 
     <th colspan="3">prop3</th> 
    </tr> 
</thead> 
<tbody> 
    <tr> 
     <td></td> 
     <td>col1</td> 
     <td>col1</td> 
     <td>col1</td> 
     <td>col2</td> 
     <td>col2</td> 
     <td>col2</td> 
     <td>col3</td> 
     <td>col3</td> 
     <td>col3</td> 
    </tr> 
</tbody> 
</table> 

活生生的例子在这里:http://jsbin.com/ateraw/

+0

感谢您的回复,但如果我在我的第二个标题行中有6'',我想为第一个标题行设置'colspan =“2”',并且它不起作用= S –

+0

@ Jerec:然后发布*代码,以便我们看到发生了什么。 –

+0

ow我明白了,我必须乘以跨越的父代的数量,以获得顶级的colspan –