I'm currently working on a simple CSS layout consisting of two panes, which sit side by side, and a footer. I have the following restrictions:
- The left-hand pane is fixed width.
- The footer is fixed height and must not fall of the bottom of the containing div.
- The remaining dimensions expand to fill the available space.
- The right-hand pane contains a lot of content. It should wrap horizontally and scroll vertically.
I have attempted to produce something suitable using flexbox. A working example can be found on jsfiddle.
HTML:
<div class="container">
<div class="top">
<div class="left">
Top-left content
</div>
<div class="right">
<div class="rightInternal">
Large content goes here.
</div>
</div>
</div>
<div class="bottom">
Bottom pane content should not collapse or be pushed outside the bounds of 'container'.
</div>
</div>
CSS:
.container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: stretch;
}
.top {
width: 100%;
flex-grow: 1;
display: flex;
flex-direction: row;
align-items: stretch;
}
.left {
width: 30%;
min-width: 30%;
}
.right {
flex-grow: 1;
overflow-y: auto;
}
.rightInternal {
display: flex;
flex-direction: column;
}
.bottom {
padding: 10px;
flex-shrink: 0;
display: flex;
justify-content: flex-end;
}
The problem:
This works fine in Chrome but the content in 'top' grows outside the bounds of 'container' in IE and FF due to the large content. Setting a height on the content of 'top' either results in the footer being pushed off the bottom (height: 100%) or the content not expanding to fill the available vertical space (height: 100px, for example).
How can I create my desired layout?
Notes:
- The JSFiddle example has been modified slightly to make container size nicely and to make everything colorful so it can be easily identified. In my actual environment, height 100% will make the container fill the visible space that it sits within, which is as desired.
- There is no requirement for me to use flexbox.