Here you can see that div while has D1, D2... data is large than the size of the div, so ideally it should have the scroll bar, but if I click on the Filter link than D1,D2... data div should increase the size, Here my data is dynamic so I can not specify any height to DIV,
(在这里,您可以看到div虽然具有D1,D2 ...数据大于div的大小,所以理想情况下它应该具有滚动条,但是如果我单击Filter链接,则比D1,D2 ... data div应该增加大小,这里我的数据是动态的,所以我不能指定DIV的任何高度,)
$(document).ready(function(){ $("#filter-text").click(function(){ var a = $("#filter-option").toggle(); if(a.css("display")=="block"){ $("#data").css("height","80%"); }else{ $("#data").css("height","96%"); } }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <div style="width:500px;height:500px;background-color:#efefef;position:absolute;"> <div id="parent" style="position:relative;"> <div id="filter" style="border:1px solid #00FF00;float:left;overflow:auto;width:100%;"> <div id="filter-text" style="cursor:pointer; color:#0000ff;height:4%;" >Filter</div> <div id="filter-option" style="height:80px;"> This should be hide on clicking of filter </div> </div> <div id="data" style="border:1px solid #0000FF;overflow:auto;float:left;width:100%;max-height:80%;position:relative;"> <table> <tr><td>This div must have scroll bar if its height is higher than parent</td></tr> <tr><td>D1</td></tr> <tr><td>D2</td></tr> <tr><td>D3</td></tr> <tr><td>D4</td></tr> <tr><td>D5</td></tr> <tr><td>D6</td></tr> <tr><td>D7</td></tr> <tr><td>D8</td></tr> <tr><td>D9</td></tr> <tr><td>D10</td></tr> <tr><td>D11</td></tr> <tr><td>D12</td></tr> <tr><td>D13</td></tr> <tr><td>D14</td></tr> <tr><td>D15</td></tr> <tr><td>D16</td></tr> <tr><td>D17</td></tr> <tr><td>D18</td></tr> <tr><td>D19</td></tr> <tr><td>D20</td></tr> </table> </div> </div> </div>
ask by Alpesh Jikadra translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…