What I'm looking for is to have a div container with any number of headers and footers, which will then have a div scroll between the different headers. The catch here is that the headers and footers cannot scroll, and the container / headers / footers can occupy any height depending on their contents.
I managed to get this working with a static header / footer size. In the code, I added a problem that I ran into: the text in the header and footer can be wrapped, which will lead to two lines. Thus, the title should be enlarged to allow this extra line, and the content should be compressed to give place to the title. Is there any way to do this without using javascript? I will know the number of headers / footers ahead of time if that helps.
This will be a component on the page, possibly with one or more pages, for example, in the 2x2 setting, where each takes fourth place in the browser window. Functionality is mostly needed because the width of the browser can change, causing the contents of the header to break a new line. This can be done quite easily with javascript, but I have always heard that resize event handlers are evil.
For example, if my 600px wrapper 600px tall, I may have 2 headers and 1 footer. Suppose that the first content of the header causes it to split into a new line, but the second header does not work. Thus, the height of the first headers is 20px , where the second is 10px . And lets say that the content of the footer also causes line breaks and therefore has a height of 20px . This gives us 50px value of the headers and footers, so now the scroller's height should be 550px .
Ascii Art:
____________________________________________ | HEADER 1 | |________breaks to new line__________________| |____________________________HEADER2_________| | | || | | || | This is my scroller | || | | || | | || | | || |_________________________________________|_|| | Some | |_____Footer_________________________________|
HTML:
<div class="wrapper"> <div class="header"> Some<br/> Header </div> <div class="scroller"> Content<br /> Content<br /> Content<br /> Content<br /> ... </div> <div class="footer"> Some<br/> Footer </div> </div>
CSS
body{ height:100%; } .wrapper{ height:400px; border-left:1px solid red; } .header, .footer{ background-color: #EEE; height:27px; } .scroller{ height:calc(100% - 54px); background-color: #CCC; overflow:auto; }
the red frame shows how far the wrapper goes down, so the footer is not displayed below. I did this instead of overflow: hidden just for debugging.
http://jsfiddle.net/yKTdz/4/