add <li> elements with search bar and prevent overflow from parent div element

add symptoms
add meaning
add definition
add in adults
add test
add treatment
add wiki
add vs adhd

I want to be able to have a user continually add entries into a search bar and for those entries to not overflow past the parent div container with the class kitchen. I am wondering if its possible to be able to set a limit on how many li elements can be added, to stop it from overflowing the div parent element.

I am wondering if this is at all possible, and what language i'd need to do it, or is overflow: scroll the only property i could set to deal with this.

ul{
    list-style-type: none;
    height: 300px;
}

li{
    float: left;
    margin-bottom: 2px;
    display: inline-block;
    color: #FFFFFF;
    border: solid 2px #FFFFFF;
    padding: 1rem;
    background: #222222;
    width: 50%;
    border-radius: 10px;
}

.fa-check-circle{
    color: green;
}

.fa-edit{
    color: red;
}

.row {
    position: relative;
    display: flex;
    flex-direction: row;
}

.kitchen{
    color: black;
    background: url('../img/refrigerator.jpg');
    background-size: cover;
    background-position: 50%;
    border: solid 5px #FFFFFF;
    padding: 3rem;
    height: 100%;
}

.col{
    width: auto;

}

.lunchbox{
    background: url('../img/lunchbox.jpg');
    background-size: cover;
    background-position: 50%;
    display: inline-block;
    border: solid 5px #FFFFFF;
    padding: 3rem;
    width: 100%;
    height: 100%;
}

.column{
    flex: 1;
    margin-top: 3rem;
    margin-right: 3rem;
    margin-left: 3rem;
    height: 600px;
}
<div class="kitchen">
  <ul class="col">
    <li>Apple<span class="far fa-check-circle"></span><span class="far fa-edit"></span></li>
    <li>Cheese <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Cereal <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Ice Cream <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Steak <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Orange <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Apple<span class="far fa-check-circle"></span><span class="far fa-edit"></span></li>
    <li>Cheese <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Cereal <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Ice Cream <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Steak <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Orange <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Apple<span class="far fa-check-circle"></span><span class="far fa-edit"></span></li>
    <li>Cheese <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Cereal <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Ice Cream <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Steak <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
    <li>Orange <span class="far fa-check-circle"></span>      <span class="far fa-edit"></span></li>
  </ul>

  <button type="button" class="clear_btn">clear items</button>

</div><!--kitchen-->

Potential solutions I see right now: 1) Overflow: scroll / overflow:hidden in your CSS stylesheet 2) Pagination. Showing eg. 10 results at once and in order to show more user will have to click "show more" or a number of "page". So if there are 23 records, than user will see buttons "1" "2" and "3". Every button will show different records. Max 10 per one view. 3) Limit the number of displayed elements with JS

ADHD vs. ADD: What's the Difference?, Understanding ADHD (or ADD) in adults. Life can be a balancing act for any adult, but if you find yourself constantly late, disorganized, forgetful, and� ADHD Relief in 30 Minutes. Break Free From Prescriptions. 100% Natural ADHD Supplement. Once You Try NaturaRelief For ADHD You'll Never Use Anything Else! Discreet Shipping

There is a css ~solution.. it hides the 4th+ elements. If you have exact number of elements to show - this works for you.

li:nth-child(n+4) {
    display: none;
}

Attention Deficit Disorder Without Hyperactivity, Attention-deficit/hyperactivity disorder (ADHD) is a disorder marked by an ongoing pattern of inattention and/or hyperactivity-impulsivity that interferes with� ADHD stands for attention deficit hyperactivity disorder, a condition with symptoms such as inattentiveness, impulsivity, and hyperactivity. The symptoms differ from person to person. ADHD was

To prevent the user from adding more objects than necessary, keep a count of how many currently exist using a global variable. Here's an example in JQuery using the applicable logic

$(document).ready(function(){
  licount = 0;
  $('li').each(function(){
    licount+=1;
  });
  $('Button').click(function(){
    if(licount<10){
      $('ul').append('<li>'+$('input').val()+'</li>');
      $('input').val('');
      licount+=1;
    }
  });
});
ul{
  width: 100px;
  list-style-type: none;
}

li{
  background-color: black;
  font-size: 20px;
  text-align: center;
  border-radius: 20px;
  color: white;
  padding: 10px;
  margin: 10px 0;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
  <li>
    test
  </li>
  <li>
    test
  </li>
  <li>
    test
  </li>
  <li>
    test
  </li>
  <li>
    test
  </li>
</ul>
<input>
</input>
<button>
  Add
</button>

ADHD in Adults, The term ADD is commonly used to describe what clinicians now call Predominantly Inattentive Type ADHD. This quieter presentation of� Add definition is - to join or unite so as to bring about an increase or improvement. How to use add in a sentence.

NIMH � Attention-Deficit/Hyperactivity Disorder, ADDA - Attention Deficit Disorder Association � Start � ADHD Test � New to ADDA � FORGE NEW CONNECTIONS � Join ADDA � What's ADHD? ADDA Resources. Most adults who face challenges with their ADHD find it most daunting in the workplace. This is not to say it’s not an issue in other areas of their lives, but when you’re struggling to keep up at work, working long hours and suffering anxiety because you know you’re not delivering up to your potential, you rarely have the time or energy left over to worry about other areas of your life

ADD vs. ADHD Symptoms: 3 Types of Attention Deficit, Amen Clinics offers attention deficit disorder treatment around the U.S. since we understand the importance of helping people overcome ADD & ADHD. ADD is a type of ADHD that doesn't involve constant movement and fidgeting. But it's a blurry distinction. The confusion dates to 1994. That's when doctors decided all forms of attention-deficit

Attention Deficit Disorder Association: Home, A.D.D. Resource Center. DSM-5 Criteria for ADHD. Accessed 10/4/2019. Children and Adults with Attention-Deficit/Hyperactivity Disorder� ADHD stands for attention deficit hyperactivity disorder. The condition used to be known as attention deficit disorder, or ADD. In 1994, ADD was renamed ADHD. As is common in conversation, for this article we will use ADD, ADHD, and AD/HD interchangeably to mean the same condition.

Comments
  • Why not just keep a count of how many have been added and disallow after a certain number?
  • oh sounds good, so do that with javascript?
  • Could you attach the current JS you have?
  • So the logic might be something like: 1) Put these items into the array 2) see how many of them are inside the array using arr.length method. 3) If there are more than eg. 6 different elements - remove the last one. After that, you render the list based on that array using eg arr.map mathod
  • It looks like your parent element has a "height" property declared in px to some particular value and after adding some elements with JS it's just becoming too small, that's why the new elements are overflowing. Is that right ? Maybe fix the parent CSS to be more flexible for new dynamically generated elements ?
  • try removing the height property
  • Aditionally, we are slightly changing the topic of your question at this point since it was originally related to limiting the items user can add
  • Yeah it's hard to tell what exactly is wrong and how it should look like. Maybe try considering marking this issue as completed and raise another one ?
  • That's a pretty good idea ! However we need to remember that with that solution, elements will be still in the DOM
  • @AdamKniec display: none; removes elements from the DOM, at least visually, unlike visibility: hidden;. You're right in that they are technically still a member of the DOM code though.
  • This is incorrect. Take a look here : css-tricks.com/forums/topic/…
  • CSS can not remove elements from the dom
  • so i could do array.from(foodItems) which could be document.querySelectorAll('.foodItems') a class I can add to all <li> elements