I have this html structure:
<body>
<div id="container">
<div id="header">Not empty</div>
<div id="content">
<div id="inner_header">Not empty</div>
<div id="scrollable_content">Very long content</div>
</div>
</div>
</body>
I want the page to have a fixed height equal to the height of the screen, and I also want a vertical scrollbar for the div scrollable_content.
I have tried with these styles, but the page I get is larger than the screen, so I get two scrollbars:
html, body {
height:100%;
}
div#container {
height:100%;
}
div#scrollable_content {
height:100%;
overflow-y:auto;
position:absolute;
}
How can I do this with CSS3?
Edit: I found a solution using jQuery (see below). I’d like to know if this is possible using only CSS3?
Thanks in advance!
When you absolutely position an element it comes out of the flow of the page. Please take a look at this fiddle. Note the green box causes two vertical scrollbars to appear.
http://jsfiddle.net/gX2DG/
To get a single scrollbar that only appears below the header, you will need to modify your CSS. This CSS works with fixed height headers only.
overflow:hiddenso that they do not trigger the main browser scrollbarhttp://jsfiddle.net/J4Ps4/