当div表格中的div具有可见性时,如何将Html表格行默认设置为无高度:无 [英] How can I get Html table row to default to no height when div within it has visibility:none

查看:158
本文介绍了当div表格中的div具有可见性时,如何将Html表格行默认设置为无高度:无的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在html中,我使用a来显示一些行,然后在每行之间是另一行包含单个行,而该行又包含一个with style:none。此行包含上面和上面的行的其他信息,可以通过单击相册行上的按钮切换显示或不显示。



麻烦是即使div被隐藏,行占据了垂直高度,我认为这是高度,但我该如何解决这个问题。或者另一个想法可以让隐藏或我可以只为div做。

 < table> 
< tr>
< td>第1列< / td>
< td>第2栏< / td>
< / tr>
< tr>
< td colspan =2>
< div id =1style =display:none>
< / div>
< / td>
< / tr>
< tr>
< td>第1列< / td>
< td>第2栏< / td>
< / tr>
< / table>

我已经完成了:

http://jsfiddle.net/ijabz/zz5zo2jh/



如果您移除隐藏的行,则其他行之间的垂直间距会减少

解决方案

将样式应用到您的表格行,不是你的div:

 < table> 
< tr>
< td>第1列< / td>
< td>第2栏< / td>
< / tr>
< tr style =display:none>
< td colspan =2>
< div id =1>
< / div>
< / td>
< / tr>
< tr>
< td>第1列< / td>
< td>第2栏< / td>
< / tr>
< / table>


In html I'm using a to display a numbers of rows, then between each row is another row containing a single , that in turn contains a with style:none. This row contains additional information for the row above and in the ful code and can be toggled to display or not by clicking on a button on the album row.

The trouble is that even when the div is hidden the row takes up vertical height, I assume this is the height of the , but how can I fix this. Or another thought can I make the hidden or can I only do that for divs.

<table>
<tr>
    <td>Column 1</td>
    <td>Column 2</td>
</tr>
<tr>
    <td colspan="2">
        <div id="1" style="display:none">
        </div>
    </td>   
</tr>    
<tr>
    <td>Column 1</td>
    <td>Column 2</td>
</tr>
</table> 

Ive done a:

http://jsfiddle.net/ijabz/zz5zo2jh/

if you remove the hidden rows there is less of a vertical gap between the other rows

解决方案

apply the style to your table row, not your div:

    <table>
<tr>
    <td>Column 1</td>
    <td>Column 2</td>
</tr>
<tr style="display:none">
    <td colspan="2">
        <div id="1">
        </div>
    </td>   
</tr>    
<tr>
    <td>Column 1</td>
    <td>Column 2</td>
</tr>
</table> 

这篇关于当div表格中的div具有可见性时,如何将Html表格行默认设置为无高度:无的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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