Home > Mobile >  Custom autocomplete doesn't go outside the div
Custom autocomplete doesn't go outside the div

Time:11-03

I checked a lot of questions on SO and a lot of them solves the opposite of what I want, and the others suggest to use absolute and relative, what I've tried, up to no avail.

I have a custom dropdown menu I made inspired by this: https://www.w3schools.com/howto/howto_js_autocomplete.asp

I use this dropdown in an overlay, but actually my list doesn't go outside the div if I have a lot of elements:

.content {
  flex-grow: 1;
  display: flex;
  height: 85%;
}

.tool {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.overlay {
  z-index: 200;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fondOverlay {
  background-color: rgba(10, 10, 10, 0.8);
  height: 100%;
  width: 100%;
  position: absolute;
  z-index: 199;
}

.contenuFormulaireOverlay {
  width: 40%;
  overflow: hidden;
  min-height: 30%;
  max-height: 60%;
  padding: 20px;
  margin: 20px;
  border: 2px solid white;
  font-variant: small-caps;
  border-radius: 30px;
  background-color: rgba(255, 255, 255, 0.8);
  z-index: 201;
  display: flex;
  font-size: 1.2em;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

.contenuFormulaireOverlay > div {
  height: 100%;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.contenuFormulaireOverlay > div > div {
    width: 100%;
    text-align: left;
    margin: 5px;
}

.autocomplete * {
  box-sizing: border-box;
}

* {
  box-sizing: border-box;
}
.autocomplete {
  position: relative;
  /* display: inline-block; */
  overflow: visible;
  width: 90%;
}
input {
  border: 1px solid transparent;
  background-color: #f1f1f1;
  padding: 10px;
  font-size: 1em;
}
input[type=text] {
  background-color: #f1f1f1;
  width: 100%;
}
.autocomplete-items {
  position: absolute;
  border: 1px solid #d4d4d4;
  border-bottom: none;
  border-top: none;
  z-index: 99;
  /*position the autocomplete items to be the same width as the container:*/
  top: 100%;
  left: 0;
  right: 0;
  text-align: left;
}
.autocomplete-items div {
  padding: 10px;
  cursor: pointer;
  background-color: #fff;
  border-bottom: 1px solid #d4d4d4;
}
.autocomplete-items div:hover {
  /*when hovering an item:*/
  background-color: #e9e9e9;
}
.autocomplete-active {
  /*when navigating through the items using the arrow keys:*/
  background-color: DodgerBlue !important;
  color: #ffffff;
}
<div class="content">
   <div class="tool">
      <header>
         <h1>TITLE</h1>
      </header>
      <div class="realContent">
        THE CONTENT
      </div>
   </div>
   <!--v-if-->
   <div class="overlay">
      <div class="fondOverlay"></div>
      <div class="contenuFormulaireOverlay">
         <div>
            <div>
               <label>POC:</label>
               <div class="autocomplete">
                  <input type="text" placeholder="Write something...">
                  <div class="autocomplete-items">
                     <div>
                        <span>            
  • Related