I'm writing a webapp that has a sidebar. The webapp fits in a div that fills the entire screen (absolutely positioned, 100% height/width). The sidebar has a title and logo at the top (fixed height), and a div below that containing a list of items. I'd like to set this list of items to overflow: auto
if they overrun the visible sidebar. I've tried using max-height: 100%
for the sidebar, but this doesn't seem invoke the scrollbars. How can I have the div fill the remaining vertical space of the sidebar, and display scrollbars if the content overruns the visible area?
+--------------------------------------------------------------------------+
| #app_pane |
| +------------------+ |
| | #sidebar | |
| | +--------------+ | |
| | | #logo | | |
| | | | | |
| | | height: 50px | | |
| | | | | |
| | +--------------+ | |
| | +--------------+ | |
| | | #list | | |
| | | | | |
| | | | | |
| | | <----+-+-----------o fill remaining height |
| | | | | and display scrollbars if necessary |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | +--------------+ | |
| +------------------+ |
+--------------------------------------------------------------------------+
edit:
Well it looks like I can do it in CSS3 with calc()
, but I'd prefer a solution that legacy browsers support.