簡體   English   中英

選擇列表高度在div內為100%

[英]Select list height 100 percent inside div

我在div內有此選擇列表,我想將高度設置為100%,而不是選擇的大小數字(大小= 10)。 我該怎么做?

我的代碼:

<div style="top:18%; left:5%; width:25%; height:40%; background: rgba(0,204,0,1); position:absolute; border:#0000FF solid 1px;">
  <table width="100%" height="10%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="left" valign="middle">Header</td>
    </tr>
  </table>  
  <div>
  <form id="form2" name="form2" method="post" action="">
      <select name="selectList" id="selectList" size="10" style="width:100%; height:50%; overflow-y:scroll;">
        <?php
        $qry= pg_query($dbconn,"select * from table") or die(pg_last_error($dbconn));
        while($row_qry = pg_fetch_assoc($qry)){
        ?>
        <option value="<?php echo $row_qry['id']; ?>"><?php echo $row_qry['name']; ?></option>
        <?php } ?>
      </select>   
  </form>  
  </div>
</div>

將HTML的高度設置為100%。 您的代碼未正確嵌套這是工作代碼

 <html>
   <head>
     <style>
       html, body {height: 100%;}
     </style>
   </head>
 <body>
    <div style="top:18%; left:5%; width:25%; height:40%; background: rgba(0,204,0,1); position:absolute; border:#0000FF solid 1px;">
       <table width="100%" height="10%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="left" valign="middle">Header</td>
          </tr>
      </table>  
      <form id="form2" name="form2" method="post" action="" style="height: 90%">
          <select name="selectList" id="selectList" size="10" style="width:100%; height:100%; overflow-y:scroll;">
              <option value=""></option>
          </select>   
        </form>  
       </div>
   </body>
 </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM