I'd like to use a div within my page that does not take up the whole screen use the scroll bars on the edge of the screen when its content overflows. I know that sounds confusing, so here's an example: http://www.csszengarden.com/?cssfile=/202/202.css&page=1
I would have posted code, but I'm not sure where to start on that. Could someone point me in the right direction with the HTML & CSS?
One trick is to overlay one or more static images or boxes and fix their position, then resize the scrollable area of your entire page, your inner
<div>
, such that its width fits in the "viewable area" exposed (i.e. not covered) by your overlaid area (you could use padding to achieve this).I've made a demo page to illustrate this. It does involve extra markup per my suggestion though; I'd wager that more sophisticated CSS is used to achieve the same effect with the same base markup provided by CSS Zen Garden, but my answer is just another simpler way of going about it.
The source code is provided below. The snippet is runnable but as the dimensions are unmodified from the original you will want to view it in full screen to see anything meaningful in action.
BoltClock answer is good when the surrounding of the div is fixed always, but when you want to use the scroll bars of the page when the div (like a modal dialog) appear on the fly it can't be used.
For this situations you can disable and hide the page scroll bars by applying this style to the body:
The given div must fill the whole page and have scroll bars:
now the div scroll bars appears exactly where page scroll bar existed and it's content would be scrollable.
when the div is closed the body overflow style must be reset.
look at this jsfiddle: http://jsfiddle.net/rahbari/kxoexa5s/