Following up on this post, I made a test, but I still got a bit of problem - the page has two scroll bars when you click to display the image.
I don't need the background scrollbar when the image is being displayed, I only need the scrollbar on the image container.
How can I hide the background scrollbar without making the page jumpy?
the css,
#container-image {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow-x: auto;
overflow-y: scroll;
z-index:100;
}
the html,
<p>Please scroll down until you see the click button</p>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<a href="#" class="get-photo">click</a>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<div id="container-image" style="display:none">
<ul id="items-image">
<li><img src="winnie-the-pooh-2011-4.jpg"/></li>
</ul>
</div>
the jquery,
$(document).ready(function(){
$('.get-photo').click(function(){
var object = $(this);
var object_path = object.attr('href');
var scroll_top = $(window).scrollTop();
//alert(object_path);
$('#container-image').show();
return false;
});
});
Here is the test page.
EDIT:
Just managed to hide the body
scrollbar and it works on all browsers accept IE8 - how can I fix IE??
$(document).ready(function(){
$('.get-photo').click(function(){
$('body').css('overflow', 'hidden');
var object = $(this);
var object_path = object.attr('href');
var scroll_top = $(window).scrollTop();
var height_document = $(document).height();
//alert(object_path);
$('#background-photo').css({
height:height_document + 'px',
display:'block'
});
$('#container-image').show();
return false;
});
$('#items-image img').click(function(){
var object = $(this);
$('body').css('overflow', 'auto');
$('#container-image').hide();
$('#background-photo').hide();
return false;
});
});
EDIT:
Fixed IE8:
$('body,html').css('overflow', 'hidden');