Although the overall effect is only possible with CSS, you probably need javascript to turn the effect on and off.
The general idea is to use position: fixed and overflow: scroll on the layer containing the image, and body - overflow: hidden . In these conditions, you can scroll the contents of the overlay, but not the body.
While this works on the desktop, on the mobile phone, everything is a little different, and all the contents will be displayed, despite the overflow: hidden on the body . Quick work is to apply position: fixed to the body . I don't know if this is the intended behavior, but it works fine in both Safari and Chrome on iOS.
Markup Outlines:
<body class="no-scroll"> <section class="content"> /* content here */ </section> <aside class="overlay"> <img src="img.jpg"> </aside> </body>
CSS
.no-scroll { overflow: hidden; position: fixed; } .overlay { overflow-y: scroll; position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: none; } .overlay img { width: 100%; height: auto; } .no-scroll .overlay { display: block; }
With this, you can use javascript to switch the no-scroll class to body . When it is there, overflowing content is hidden and overlay displayed. When he is absent there, overlay is hidden.
Here is an example effect (without the .no-scroll and javascript class, however, to show that it works):
Edit:
In the above example, I gave overlay translucent background and gave a max-width image of 100% inside it. If you want the entire screen to be filled with an image, change max-width to normal width .
Edit 2:
As requested here, the jQuery function to switch the effect.
$(".close").click(function() { $("body").toggleClass("no-scroll"); });
Just give <button> or any other close class name, and it will turn the effect on and off.