Reputation: 2615
I'm working on this site: http://www.massobservation.org. If you click on 'Information' a div is displayed on top of the content, an overlay if you will. However, I'd like the site, when the overlay is active, to only be scrollable as far as the content of the overlay div. You can see however, that even though the overlay ends (the yellow background ends) the site still scrolls to the bottom.
An example of this is given here: http://cargocollective.com/montessori
Any ideas? Many thanks in advance.
Upvotes: 2
Views: 4184
Reputation: 102745
As long as the overlay is not a child element of #top
, this should work:
When the overlay opens, add this style to your main content:
#top {
position: fixed;
}
When the overlay closes, remove the style.
Upvotes: 2
Reputation: 66663
When showing the overlay, you can do something like:
a) Turn off scroll for main document - $(document).css('overflow', 'hidden');
b) Set height of overlay to window's height - $(overlay).css('height', $(window).height()+'px');
c) Set overflow: auto for overlay - $(overlay).css('overflow', 'auto');
That should ensure that scroll works only till the end of content in the overlay.
Upvotes: 0
Reputation: 82219
What you could try is:
This should mean that only the overlay content causes the browser to scroll.
Upvotes: 0