javascript td colspan 不适用于带有 id 的 tr
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19784298/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
td colspan not working for tr with ids
提问by Nitish
I have a table structure similar to below:
我有一个类似于下面的表结构:
<tr>
<td colspan="5">
TEST
</td>
</tr>
<tr id="abcd_<?php echo $id; ?>" style="display: none">
<td colspan="5">
<span id="hidtb_<?php echo $id; ?>"></span>
</td>
</tr>
The table is within a loop and the value of $idchanges. The second tris set to display : blockusing javascript. But the <td colspan="5">is not covering all the five <td>s, instead only one .
. Why my colspanis not working ?
该表在一个循环内并且值发生$id变化。第二个tr设置为display : block使用javascript。但是 <td colspan="5">并没有涵盖所有五个<td>s,而是只有一个。
. 为什么我colspan的不工作?
回答by Legionar
This is the problem with display: block.
这是display: block.
Please refer the below link http://thedesignspace.net/MT2archives/000376.html#.UUrg3FfCd1u
请参考以下链接 http://thedesignspace.net/MT2archives/000376.html#.UUrg3FfCd1u
If you are hiding tr, then use display: table-rowinstead of display: blockto display that tr.
如果您正在隐藏tr,则使用display: table-row而不是display: block显示它tr。
If you are hiding td, then use display: table-cellinstead of display: blockto display that td.
如果您正在隐藏td,则使用display: table-cell而不是display: block显示它td。
Use table-row, no blockwhen styling a tr. Perfect!
使用table-row, noblock造型 a 时tr。完美的!

