简体   繁体   中英

Set limit size for div box

So I have this box with some values from database and when I add more values they come out from the box. Is there anyway to solve this?

<div class="check">
   <?php
     $result = mysqli_query($conn, "SELECT * FROM `material` WHERE id > 0");
     while($row = mysqli_fetch_assoc($result)):?>
       <input type="checkbox" value="<?php echo $row['id'];?>" name="tipo[]" 
       id="tipo"><label><?php echo $row['tipo'];?></label><br>
       <input type="number" name="quant[]" min="1" max="50" id="textnumber" 
       class="number" disabled="true" style="margin-left: 145px; margin-top: 
       -36px; width: 40px; position: absolute;">
   <?php endwhile?>
</div>

There's a few strange things in that snippet of code (ie I don't think the position: absolute on the input is required), but just to focus on your question:

I'm guessing you're using some CSS somewhere to set the height of the check div.

Add an overflow: hidden to that to hide anything that doesn't fit in the box:

.check {
   height: 100px;
   overflow: hidden;
}

Or use overflow: auto to make it scrollable when the content doesn't fit:

.check {
   height: 100px;
   overflow: auto;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM