title: Disable Scroll in Relation to Overlay
body: <p>Goal:<br>
  When you click on the picture a overlay should display and the scroll should not affect the user interface.  </p>
  
  <p>Problem:<br>
  When the page is long and you disable the scroll the content of the page in relation to overlay will be moved towards to the right side. When you have many picture, it will not be very user-friendly.</p>
  
  <p>I have tried the solution from this <a href="https://stackoverflow.com/questions/8701754/just-disable-scroll-not-hide-it">page</a> and this <a href="https://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily?rq=1">page</a>
   but they doesn't work in relation to this source code below.</p>
  
  <p>I also have tried this <a href="https://stackoverflow.com/questions/9280258/prevent-body-scrolling-but-allow-overlay-scrolling">page</a> but it did't work at all. This link as a proposal. <code>jsbin.com/poyejulijo/edit?html,output</code></p>
  
  <p>I have tried different solution but I failed.</p>
  
  <p>Info:<br>
  *Using jQuery and Bootstrap v.3<br>
  *The overlay with scroll should be working in relation to the latest version of IE, FF and Chrome. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function openNav(a) {
      document.getElementById("myNav").style.width = "100%";
         
      var p = document.getElementById("p1");
   p.src = a.getElementsByTagName('img')[0].src;
   
      var d = document.getElementById("div12");
   d.innerHTML = d.innerHTML + 'sdfsdf';
   
   document.body.classList.add("noScroll");
  }
  
  function closeNav() {
      document.getElementById("myNav").style.width = "0%";
  
   document.body.classList.remove("noScroll"); 
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.overlay {
      height: 100%;
      width: 0;
      position: fixed;
      z-index: 1;
      top: 0;
      left: 0;
      background-color: rgb(0,0,0);
      background-color: rgba(0,0,0, 0.7);
      overflow-x: hidden;
  }
  
  .overlay-content {
      position: relative;
      top: 25%;
      width: 100%;
      text-align: center;
      margin-top: 30px;
  
  }
  
  .overlay a {
      padding: 8px;
      text-decoration: none;
      font-size: 36px;
      color: #818181;
      display: block;
  }
  
  .overlay a:hover, .overlay a:focus {
      color: #f1f1f1;
  }
  
  .overlay .closebtn {
      position: absolute;
      top: 20px;
      right: 45px;
      font-size: 60px;
  }
  
  body.noScroll { /* ...or body.dialogShowing */
    overflow: hidden;
  }
  
  
  
  
  
  @media screen and (max-height: 450px) {
    .overlay a {font-size: 20px}
    .overlay .closebtn {
      font-size: 40px;
      top: 15px;
      right: 35px;
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/&gt;
  &lt;link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.css" rel="stylesheet"/&gt;
  &lt;script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  
  
  
   &lt;div id="myNav" class="overlay"&gt;
    &lt;a href="javascript:void(0)" class="closebtn" onclick="closeNav()"&gt;&amp;times;&lt;/a&gt;
    &lt;div class="overlay-content"&gt;
     &lt;img id="p1" src="" /&gt;
     &lt;div id="div12"&gt;
     &lt;/div&gt;
    &lt;/div&gt;
   &lt;/div&gt;
  
  
      &lt;nav class="navbar navbar-fixed-top navbar-inverse"&gt;
    &lt;div class="container"&gt;
     &lt;div class="navbar-header"&gt;
      &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"&gt;
       &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
       &lt;span class="icon-bar"&gt;&lt;/span&gt;
       &lt;span class="icon-bar"&gt;&lt;/span&gt;
       &lt;span class="icon-bar"&gt;&lt;/span&gt;
      &lt;/button&gt;
      &lt;a class="navbar-brand" href="#"&gt;Project name&lt;/a&gt;
     &lt;/div&gt;
     &lt;div id="navbar" class="collapse navbar-collapse"&gt;
      &lt;ul class="nav navbar-nav"&gt;
       &lt;li class="active"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="#about"&gt;About&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="#contact"&gt;Contact&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
     &lt;/div&gt;&lt;!-- /.nav-collapse --&gt;
    &lt;/div&gt;&lt;!-- /.container --&gt;
      &lt;/nav&gt;&lt;!-- /.navbar --&gt;
  
      &lt;div class="container"&gt;
  
    &lt;div class="row row-offcanvas row-offcanvas-right"&gt;
  
     &lt;div class="col-xs-12 col-sm-9"&gt;
      &lt;p class="pull-right visible-xs"&gt;
       &lt;button type="button" class="btn btn-primary btn-xs" data-toggle="offcanvas"&gt;Toggle nav&lt;/button&gt;
      &lt;/p&gt;
      &lt;div class="jumbotron"&gt;
       &lt;h1&gt;Hello, world!&lt;/h1&gt;
       &lt;p&gt;This is an example to show the potential of an offcanvas layout pattern in Bootstrap. Try some responsive-range viewport sizes to see it in action.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
       &lt;div class="col-xs-6 col-lg-4"&gt;
        &lt;h2&gt;Heading&lt;/h2&gt;
        &lt;p&gt;
         &lt;div style="font-size:30px;cursor:pointer" onclick="openNav(this)"&gt;
          &lt;img src="http://www.partycity.com/images/products/en_us/gateways/candy-2015/candy-by-type/candy-by-type-lollipops.jpg"  /&gt;
         &lt;/div&gt;
         &lt;br /&gt;
         &lt;br /&gt;
         &lt;br /&gt;
         &lt;br /&gt;
         &lt;br /&gt;
  
         &lt;img onclick="openNav(this)" src="http://www.partycity.com/images/products/en_us/gateways/candy-2015/candy-by-type/candy-by-type-lollipops.jpg"  /&gt;
        &lt;/p&gt;
        &lt;p&gt;&lt;a class="btn btn-default" href="#" role="button"&gt;View details &amp;raquo;&lt;/a&gt;&lt;/p&gt;
       &lt;/div&gt;&lt;!--/.col-xs-6.col-lg-4--&gt;
      &lt;/div&gt;&lt;!--/row--&gt;
     &lt;/div&gt;&lt;!--/.col-xs-12.col-sm-9--&gt;
  
     &lt;div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar"&gt;
      &lt;div class="list-group"&gt;
       &lt;a href="#" class="list-group-item active"&gt;Link&lt;/a&gt;
       &lt;a href="#" class="list-group-item"&gt;Link&lt;/a&gt;
       &lt;a href="#" class="list-group-item"&gt;Link&lt;/a&gt;
       &lt;a href="#" class="list-group-item"&gt;Link&lt;/a&gt;
       &lt;a href="#" class="list-group-item"&gt;Link&lt;/a&gt;
       &lt;a href="#" class="list-group-item"&gt;Link&lt;/a&gt;
       &lt;a href="#" class="list-group-item"&gt;Link&lt;/a&gt;
       &lt;a href="#" class="list-group-item"&gt;Link&lt;/a&gt;
       &lt;a href="#" class="list-group-item"&gt;Link&lt;/a&gt;
       &lt;a href="#" class="list-group-item"&gt;Link&lt;/a&gt;
      &lt;/div&gt;
     &lt;/div&gt;&lt;!--/.sidebar-offcanvas--&gt;
    &lt;/div&gt;&lt;!--/row--&gt;
  
    &lt;hr&gt;
  
    &lt;footer&gt;
    &lt;p&gt;&amp;copy; 2016 Company, Inc.&lt;/p&gt;
    &lt;/footer&gt;
  
      &lt;/div&gt;&lt;!--/.container--&gt;
  
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;</code></pre>
  </div>
  </div>
  </p>