title: How to prevent an absolutely positioned element to affect the scrollbar?
body: <p>Consider an autosuggest input sitting in a container with some content and a vertical scrollbar:</p>
  
  <p><a href="https://i.stack.imgur.com/kMGld.png"><img src="https://i.stack.imgur.com/kMGld.png" alt="enter image description here"></a></p>
  
  <p>When autosuggest suggestions are shown, they should appear on top of the content <strong>without affecting container's scrollbar</strong>.</p>
  
  <p>I expect to get:</p>
  
  <p><a href="https://i.stack.imgur.com/7G2n7.png"><img src="https://i.stack.imgur.com/7G2n7.png" alt="enter image description here"></a></p>
  
  <p>Note that the scrollbar is exactly the same as above.</p>
  
  <p>But, I get the following:</p>
  
  <p><a href="https://i.stack.imgur.com/L8TsK.png"><img src="https://i.stack.imgur.com/L8TsK.png" alt="enter image description here"></a></p>
  
  <p>Note that the scrollbar is affected, and suggestions are cut.</p>
  
  <p>Why absolutely positioned suggestions affect container's scrollbar?</p>
  
  <p>How would you fix that?</p>
  
  <p><a href="http://jsbin.com/rebohojopa/1/edit?html,css,output">Playground here</a></p>
  
  <p>Notes:</p>
  
  <ul>
  <li>When scrolling the container, the input and suggestions should move together. </li>
  <li>You are allowed to modify the HTML, but the input and the suggestions list should stay inside <code>.autosuggest</code> (consider <code>.autosuggest</code> as a third party component whose HTML cannot be changed, but you can change its CSS).</li>
  <li>You can use flexbox, if it helps.</li>
  <li>I'm looking for CSS only solution. No Javascript please.</li>
  </ul>
  
  <hr>
  
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
    height: 100px;
    width: 300px;
    margin-top: 50px;
    overflow-y: auto;
    border: 1px solid black;
  }
  .autosuggest {
    position: relative;
    width: 250px;
  }
  .input {
    font-size: 16px;
    width: 230px;
    padding: 5px 10px;
    border: 0;
    background-color: #FFEBBF;
  }
  .suggestions {
    list-style-type: none;
    margin: 0;
    padding: 5px 10px;
    width: 230px;
    background-color: #85DDFF;
    position: absolute;
  }
  .content {
    width: 120px;
    padding: 5px 10px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
    &lt;div class="autosuggest"&gt;
      &lt;input class="input" type="text" value="input"&gt;
    &lt;/div&gt;
    &lt;div class="content"&gt;
      content content content content content content content content content content
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="container"&gt;
    &lt;div class="autosuggest"&gt;
      &lt;input class="input" type="text" value="input"&gt;
      &lt;ul class="suggestions"&gt;
        &lt;li&gt;suggestion 1&lt;/li&gt;
        &lt;li&gt;suggestion 2&lt;/li&gt;
        &lt;li&gt;suggestion 3&lt;/li&gt;
        &lt;li&gt;suggestion 4&lt;/li&gt;
        &lt;li&gt;suggestion 5&lt;/li&gt;
        &lt;li&gt;suggestion 6&lt;/li&gt;
        &lt;li&gt;suggestion 7&lt;/li&gt;
        &lt;li&gt;suggestion 8&lt;/li&gt;
        &lt;li&gt;suggestion 9&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
    &lt;div class="content"&gt;
      content content content content content content content content content content
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>