I have a website with a side-bar navigation and a main content pane, wrapped in a container element. The content has a background of its own, while the menu borrows that of the parent container.
In cases where the sidebar is longer than the content, I need the content element to stretch all the way down to cover the same height, so that the content background makes up the majority of the screen space to keep the design from looking silly.
This works beautifully by giving the container display: table
and both children display: table-cell
. This will place them next to each other and ensure that they're always the same height.
However, now I want to have two lesser navigation bars in the content. One fixed to the top, one to the bottom of the pane. I use position: relative
on the content and position: absolute
on the nav bars to achieve this.
This solution works perfectly on modern browsers, but Firefox versions before 31 do not accept position: relative on table-cell elements, and the navbars are positioned relatively to the document body.
Can I somehow make this solution work on all common browsers? I need to maintain that the content element stretches down with the sidebar.
Links:
A simplified code example:
div {
display: table;
width: 100%;
}
nav {
vertical-align: top;
display: table-cell;
width: 25%;
}
main {
display: table-cell;
position: relative;
}
main header,
main footer {
position: absolute;
}
main header {
top: 0;
}
main footer {
bottom: 0;
}
<div>
<nav>
Sidebar
</nav>
<main>
<header>
Top navbar
</header>
Content
<footer>
Bottom navbar
</footer>
</main>
</div>