title: How to make scrollbar disappear when not needed?
body: <p>I'm trying to set up a responsive site for multiple sized screens, e.g. Bootstrap sizes <code>xs</code>, <code>sm</code>, <code>md</code>, and <code>lg</code>.</p>
  
  <p>Everything works fine on the three smaller sizes, i.e. the scrollbar is only present on the right side when it is needed. </p>
  
  <p>However, on the <strong>large size screen</strong>, which has a 1024px width so that it doesn't get too wide, <strong>how can I get the vertical scrollbar to only appear when it is needed?</strong></p>
  
  <p><strong>SMALLER SIZES OK:</strong>
  <a href="https://i.stack.imgur.com/n703M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n703M.png" alt="enter image description here"></a></p>
  
  <p><strong>LARGE SIZE has unnecessary scrollbar when not needed:</strong> 
  <a href="https://i.stack.imgur.com/X8yK0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X8yK0.png" alt="enter image description here"></a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.pagecontent {
    margin: 0 18px;
  }
  /* bootstrap override */
  
  .container {
    width: 100%;
    padding: 0;
  }
  .navbar {
    border-radius: 0px;
  }
  .navbar-text {
    float: left !important;
    margin-right: 10px;
  }
  .navbar-right {
    float: right!important;
  }
  .navbar-nav&gt;li&gt;a {
    padding-top: 15px;
    padding-bottom: 15px;
  }
  .navbar-nav {
    margin-bottom: 0;
    margin-top: 0;
    margin-left: 0;
  }
  .container {
    width: 1024px;
    padding: 0;
    background-color: #fff;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: scroll;
  }
  html {
    min-height: 100%;
    /* make sure it is at least as tall as the viewport */
    position: relative;
  }
  body {
    height: 100%;
    /* force the BODY element to match the height of the HTML element */
    background-color: #999;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"&gt;
    &lt;script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
    &lt;div class="container"&gt;
      &lt;nav class="navbar navbar-inverse"&gt;
        &lt;div class="container-fluid"&gt;
          &lt;div class="navbar-header pull-left"&gt;
            &lt;a class="navbar-brand" href="?"&gt;Bootstrap Showcase&lt;/a&gt;
          &lt;/div&gt;
  
        &lt;/div&gt;
      &lt;/nav&gt;
      &lt;div class="pagecontent"&gt;
  
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
        &lt;div&gt;this is a test line&lt;/div&gt;
  
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>ADDENDUM:</strong></p>
  
  <p>If I remove <code>overflow-y: scroll</code>, I get the scrollbar on the right, but the content then extends before the bottom:</p>
  
  <p><a href="https://i.stack.imgur.com/PeWCC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PeWCC.png" alt="enter image description here"></a></p>