css/javascript - How to achieve these unusual design requirements?

CootImatpeame

New Member
I have a header div and footer div. The header div never moves; however, the footer div must stay at the bottom of the window regardless of the screen size, i.e., a "sticky footer." In between these two divs is a dynamically populated content div. [*]The bottom of the content div sits directly atop the footer div, and it must move up and down with the footer div (when the screen size vertically expands and contracts.) It too can be considered "sticky." [*]However, if there is enough content, the content div must expand vertically (the bottom of the content div still remaining directly atop the footer div) to accommodate as much of the content as possible. This will happen until the top of the content div runs into the header div...[*]Then, if there is too much content to display between the header and footer divs, the content div will become scrollable, with the height of the content div contracting so as to never overlap with the header div or overlap with the footer div. [*]And again, the content div can never overlap the header div or the footer div. If there is not enough room between the two divs to display all the content in one view, the content div must become scrollable \[code\]overflow-y: scroll;\[/code\]. This explains my (fruitless) attempts so far:
I have yet to successfully accomplish any of this. What I do have is minimal, and, essentially useless. Some of my problems I have are: If I make the footer div \[code\]position: absolute; bottom: 0px;\[/code\] It will be a "sticky footer" and remain on the bottom of my screen regardless of vertical screen size. However, with this absolute positioning, the content div will happily overlap with the footer. I tried to prevent this by making the content div \[code\]position: absolute; bottom: 180px;\[/code\]. The \[code\]180px\[/code\] is the height of my footer div. This works...a little. It rapidly becomes a problem when content needs to be dynamically added. The top of the content div will quickly overlap with the header div... So then I set a fixed height for the content div, and enable scrolling when it exceeds that height, but that does not take into account a screen larger than my own where there may be more room to display content.Ultimately, none of this works the way I need it to. What is the best way to accomplish this using CSS and/or javascript (if required)? And, is there a good starting point to get me on the right track that you may know of?
Thank you for your help!
 
Back
Top