关于<div>中的style的overflow:hidden失效的问题,全分相送 本帖最后由 kd55850818 于 2010-04-22 16:27:57 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 document.write("<div id=\""+nodeValues[0]+"\" ; overflow : hidden ; height: 0px \">---》》》document.write("<div id=\""+nodeValues[0]+"\" style=\"overflow : hidden ; height: 0px \"> overflow是设置滚动条的,如果你要让DIV不显示的话,用display: none;在JAVASCRIPT里面控制DIV显示不显示用下面的代码. style="display: none;" document.getElementById("typediv1").style.display="none";//隐藏 document.getElementById("typediv1").style.display="";//显示 display:none我也用过这个属性,但是我这里是要通过控制height的值实现动态的滚动效果 下面这样生成的HTML文件,表格内容是显示不出来的.还是你的JAVASCRIPT逻辑有问题吧?<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Insert title here</title></head><body><div style="overflow:hidden; height:0px; "><table><tbody><tr><td>aaaa</td><td>bbbb</td></tr><tr><td>aaaa</td><td>bbbb</td></tr></tbody></table></div></body></html> 源码我看过了,没有问题,我把问题稍微改改也许更方便回答。譬如我写了个JSP页面,body代码如下<body> <table cellspacing="0" cellpadding="0" width="193" border="0"> <tbody> <tr onmouseover="this.className = 'showLine';" onclick="isShow(document.getElementById('menu_1'), 'menu_1');" onmouseout="this.className = '';"> <td background="../style/images/left_title_bg.jpg" height="29"> <div class="title_font" align="center"> 评估反馈 </div> </td> </tr> <tr> <td valign="top" background="images/left_bg.gif"> <div id="menu_1" style="OVERFLOW: hidden;height:0px"> <table style="MARGIN: 0px" cellspacing="0" cellpadding="0" width="100%" border="0"> <tbody> <tr onmouseover="className += ' showLine menuMouse';" onmouseout="className = className.replace('showLine menuMouse', '');" class="left_menu"> <td height="33" align="left"> <div class="left_table"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" align="center"> <img src="../style/images/left_menu_1.gif" width="16" height="16" border="0" /> </td> <td align="left"> <a href="评估实施.html" target="mainFrame">评估实施</a> </td> </tr> </table> </div> </td> </tr> <tr onmouseover="className += ' showLine menuMouse';" onmouseout="className = className.replace('showLine menuMouse', '');" class="left_menu"> <td height="33" align="left"> <div class="left_table"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" align="center"> <img src="../style/images/left_menu_2.gif" width="16" height="16" border="0" /> </td> <td align="left"> <a href="实施管理1.html" target="mainFrame">实施管理</a> </td> </tr> </table> </div> </td> </tr> <tr onmouseover="className += ' showLine menuMouse';" onmouseout="className = className.replace('showLine menuMouse', '');" class="left_menu"> <td height="33" align="left"> <div class="left_table"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" align="center"> <img src="../style/images/left_menu_3.gif" width="15" height="16" border="0" /> </td> <td align="left"> <a href="评估查询.html" target="mainFrame">评估查询</a> </td> </tr> </table> </div> </td> </tr> </tbody> </table> </div> </td> </tr> <tr onmouseover="this.className = 'showLine';" onclick="isShow(document.getElementById('menu_2'), 'menu_2');" onmouseout="this.className = '';"> <td background="../style/images/left_title_bg.jpg" height="29"> <div class="title_font" align="center"> 评估管理 </div> </td> </tr> <tr> <td valign="top" background="images/left_bg.gif"> <div id="menu_2" style="OVERFLOW: hidden; HEIGHT: 0px"> <table style="MARGIN: 0px" cellspacing="0" cellpadding="0" width="100%" border="0"> <tbody> <tr onmouseover="className += ' showLine menuMouse';" onmouseout="className = className.replace('showLine menuMouse', '');" class="left_menu"> <td height="33" align="left"> <div class="left_table"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" align="center"> <img src="../style/images/left_menu_8.gif" width="16" height="16" border="0" /> </td> <td align="left"> <a href="模板管理1.html" target="mainFrame">评估模板</a> </td> </tr> </table> </div> </td> </tr> <tr onmouseover="className += ' showLine menuMouse';" onmouseout="className = className.replace('showLine menuMouse', '');" class="left_menu"> <td height="33" align="left"> <div class="left_table"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" align="center"> <img src="../style/images/left_menu_9.gif" width="16" height="16" border="0" /> </td> <td align="left"> <a href="评估方式.html" target="mainFrame">评估方式</a> </td> </tr> </table> </div> </td> </tr> <tr onmouseover="className += ' showLine menuMouse';" onmouseout="className = className.replace('showLine menuMouse', '');" class="left_menu"> <td height="33" align="left"> <div class="left_table"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" align="center"> <img src="../style/images/left_menu_17.gif" width="16" height="16" border="0" /> </td> <td align="left"> <a href="维度管理.html" target="mainFrame">维度管理</a> </td> </tr> </table> </div> </td> </tr> <tr onmouseover="className += ' showLine menuMouse';" onmouseout="className = className.replace('showLine menuMouse', '');" class="left_menu"> <td height="33" align="left"> <div class="left_table"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" align="center"> <img src="../style/images/left_menu_18.gif" width="16" height="16" border="0" /> </td> <td align="left"> <a href="指标管理1.html" target="mainFrame">指标管理</a> </td> </tr> </table> </div> </td> </tr> <tr onmouseover="className += ' showLine menuMouse';" onmouseout="className = className.replace('showLine menuMouse', '');" class="left_menu"> <td height="33" align="left"> <div class="left_table"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20" align="center"> <img src="../style/images/left_menu_21.gif" width="14" height="16" border="0" /> </td> <td align="left"> <a href="人员管理1.html" target="mainFrame">人员管理</a> </td> </tr> </table> </div> </td> </tr> </tbody> </table> </div> </td> </tr> </tbody> </table></body><div style="overflow:hidden;height:0px">,但是现实效果仍然是所有的子节点都是打开的。期待高手出现,谢谢`` 是这样,首先生成trtd的JavaScript是没有问题的,我查看了源代码.其次我在静态页面上这么写,也是不现实的,但是放到jsp里面写就无法实现这样的效果。而且JavaScript只是我点击之后或者onmouse时才会被激活,是否能够正常实现效果,应该跟JavaScript没关系才对. 是这样,首先生成trtd的JavaScript是没有问题的,我查看了源代码.其次我在静态页面上这么写,也是不现实的,但是放到jsp里面写就无法实现这样的效果。而且JavaScript只是我点击之后或者onmouse时才会被激活,是否能够正常实现效果,应该跟JavaScript没关系才对. lz用的浏览器是什么版本?估计是浏览器兼容问题。一点建议,最好用JQuery来控制,或者用一些现成的js库。 <div id="menu_2" style="OVERFLOW: hidden; HEIGHT: 0px">--->>>> <div id="menu_2" style="display:none; HEIGHT: 0px">上面的---------------<tr onmouseover="this.className = 'showLine';" onclick="isShow(document.getElementById('menu_1'), 'menu_1');" onmouseout="this.className = '';">---->>>>>>>onclick调用的js的function里面:document.getElementById('menu_1').style.display='';来显示这一个指定的id的div我js很弱的,最近也在整这个,烦啊 我这里之所以要用overflow:hidden和 height:0px来控制它就是想要缓慢展开的效果(随着e.style.height的值的增加,div一点一点的展现开).display:none虽然可以实现隐藏效果,不过无法实现这个效果.我js也很弱,所以在求助,期盼高手出现. Delphi与Java用Socket通信 判断email是否真实存在 struts form 取值默认值问题 关于乱码问题~~ 数据库查询问题,有高手帮忙进来解决下! struts高手请进呀!(急SOS) 数据转换问题!在线等。 JSTL环境下能否在JSP里同时使用EL和传统JSP标签? 自己写的dbutil,出现大量资源不能释放的情况,求解! start tomat7的时候就弹出错误对话框 iframe 加载本地页面不显示怎么办?? 关于JS发送Ajax到servlet的问题
---》》》document.write("<div id=\""+nodeValues[0]+"\" style=\"overflow : hidden ; height: 0px \">
style="display: none;"
document.getElementById("typediv1").style.display="none";//隐藏
document.getElementById("typediv1").style.display="";//显示
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<div style="overflow:hidden; height:0px; ">
<table>
<tbody>
<tr>
<td>
aaaa
</td>
<td>
bbbb
</td>
</tr>
<tr>
<td>
aaaa
</td>
<td>
bbbb
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
我把问题稍微改改也许更方便回答。
譬如我写了个JSP页面,body代码如下<body>
<table cellspacing="0" cellpadding="0" width="193" border="0">
<tbody> <tr onmouseover="this.className = 'showLine';"
onclick="isShow(document.getElementById('menu_1'), 'menu_1');"
onmouseout="this.className = '';">
<td background="../style/images/left_title_bg.jpg" height="29">
<div class="title_font" align="center">
评估反馈
</div>
</td>
</tr>
<tr>
<td valign="top" background="images/left_bg.gif">
<div id="menu_1" style="OVERFLOW: hidden;height:0px"> <table style="MARGIN: 0px" cellspacing="0" cellpadding="0"
width="100%" border="0">
<tbody>
<tr onmouseover="className += ' showLine menuMouse';"
onmouseout="className = className.replace('showLine menuMouse', '');"
class="left_menu">
<td height="33" align="left">
<div class="left_table">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center">
<img src="../style/images/left_menu_1.gif" width="16" height="16"
border="0" />
</td>
<td align="left">
<a href="评估实施.html" target="mainFrame">评估实施</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr onmouseover="className += ' showLine menuMouse';"
onmouseout="className = className.replace('showLine menuMouse', '');"
class="left_menu">
<td height="33" align="left">
<div class="left_table">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center">
<img src="../style/images/left_menu_2.gif" width="16" height="16"
border="0" />
</td>
<td align="left">
<a href="实施管理1.html" target="mainFrame">实施管理</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr onmouseover="className += ' showLine menuMouse';"
onmouseout="className = className.replace('showLine menuMouse', '');"
class="left_menu">
<td height="33" align="left">
<div class="left_table">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center">
<img src="../style/images/left_menu_3.gif" width="15" height="16"
border="0" />
</td>
<td align="left">
<a href="评估查询.html" target="mainFrame">评估查询</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</tbody>
</table> </div>
</td>
</tr>
<tr onmouseover="this.className = 'showLine';"
onclick="isShow(document.getElementById('menu_2'), 'menu_2');"
onmouseout="this.className = '';">
<td background="../style/images/left_title_bg.jpg" height="29">
<div class="title_font" align="center">
评估管理
</div>
</td>
</tr>
<tr>
<td valign="top" background="images/left_bg.gif">
<div id="menu_2" style="OVERFLOW: hidden; HEIGHT: 0px"> <table style="MARGIN: 0px" cellspacing="0" cellpadding="0"
width="100%" border="0">
<tbody>
<tr onmouseover="className += ' showLine menuMouse';"
onmouseout="className = className.replace('showLine menuMouse', '');"
class="left_menu">
<td height="33" align="left">
<div class="left_table">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center">
<img src="../style/images/left_menu_8.gif" width="16" height="16"
border="0" />
</td>
<td align="left">
<a href="模板管理1.html" target="mainFrame">评估模板</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr onmouseover="className += ' showLine menuMouse';"
onmouseout="className = className.replace('showLine menuMouse', '');"
class="left_menu">
<td height="33" align="left">
<div class="left_table">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center">
<img src="../style/images/left_menu_9.gif" width="16" height="16"
border="0" />
</td>
<td align="left">
<a href="评估方式.html" target="mainFrame">评估方式</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr onmouseover="className += ' showLine menuMouse';"
onmouseout="className = className.replace('showLine menuMouse', '');"
class="left_menu">
<td height="33" align="left">
<div class="left_table">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center">
<img src="../style/images/left_menu_17.gif" width="16" height="16"
border="0" />
</td>
<td align="left">
<a href="维度管理.html" target="mainFrame">维度管理</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr onmouseover="className += ' showLine menuMouse';"
onmouseout="className = className.replace('showLine menuMouse', '');"
class="left_menu">
<td height="33" align="left">
<div class="left_table">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center">
<img src="../style/images/left_menu_18.gif" width="16" height="16"
border="0" />
</td>
<td align="left">
<a href="指标管理1.html" target="mainFrame">指标管理</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr onmouseover="className += ' showLine menuMouse';"
onmouseout="className = className.replace('showLine menuMouse', '');"
class="left_menu">
<td height="33" align="left">
<div class="left_table">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20" align="center">
<img src="../style/images/left_menu_21.gif" width="14" height="16"
border="0" />
</td>
<td align="left">
<a href="人员管理1.html" target="mainFrame">人员管理</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</body><div style="overflow:hidden;height:0px">,但是现实效果仍然是所有的子节点都是打开的。
期待高手出现,谢谢``
是这样,首先生成trtd的JavaScript是没有问题的,我查看了源代码.其次我在静态页面上这么写,也是不现实的,但是放到jsp里面写就无法实现这样的效果。
而且JavaScript只是我点击之后或者onmouse时才会被激活,是否能够正常实现效果,应该跟JavaScript没关系才对.
是这样,首先生成trtd的JavaScript是没有问题的,我查看了源代码.其次我在静态页面上这么写,也是不现实的,但是放到jsp里面写就无法实现这样的效果。
而且JavaScript只是我点击之后或者onmouse时才会被激活,是否能够正常实现效果,应该跟JavaScript没关系才对.
一点建议,最好用JQuery来控制,或者用一些现成的js库。
<div id="menu_2" style="display:none; HEIGHT: 0px">
上面的---------------
<tr onmouseover="this.className = 'showLine';"
onclick="isShow(document.getElementById('menu_1'), 'menu_1');"
onmouseout="this.className = '';">---->>>>>>>
onclick调用的js的function里面:
document.getElementById('menu_1').style.display='';
来显示这一个指定的id的div我js很弱的,最近也在整这个,烦啊
我这里之所以要用overflow:hidden和 height:0px来控制它就是想要缓慢展开的效果(随着e.style.height的值的增加,div一点一点的展现开).display:none虽然可以实现隐藏效果,不过无法实现这个效果.我js也很弱,所以在求助,期盼高手出现.