I've created a simple set of css classes that achieve the following:
- Will take up all the space of the container provided.
- Will allow unlimited nesting of vertical and horizontal layouts.
- Will allow scrollable content in any section.
- Will allow the size (width or height) of growing sections to take up the space they need and not more.
- Allow the "growing" sections to take all available space.
My example is working in Chrome, but not in Firefox. I'm not sure if Chrome or Firefox is rendering correctly according to the spec. Either way, I'd like to find out how to achieve what is working in Chrome in all modern browsers.
Example:
https://jsfiddle.net/5a95f2a1/5/
CSS:
.some-stray-container {
margin: 5vh 5vw;
background: gray;
height: 90vh;
width: 90vw;
display: flex;
flex-direction: column;
}
.content {
padding: .5em;
}
.layout-vertical {
align-self: stretch;
background: #F1F1F1;
flex-grow: 1;
display: flex;
flex-direction: column;
align-items: stretch;
}
.layout-vertical-section {
background: linear-gradient(transparent, #DDDDDD);
}
.layout-vertical-section.grow {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.layout-horizontal {
align-self: stretch;
background: #CCCCCC;
flex-grow: 1;
display: flex;
flex-direction: row;
align-items: stretch;
}
.layout-horizontal-section {
background: linear-gradient(90deg, transparent, #AAAAAA);
display: flex;
flex-direction: column;
}
.layout-horizontal-section.grow {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.layout-horizontal-section.panel {
width: 300px;
}
.content-scroll {
align-self: stretch;
flex-grow: 1;
overflow: auto;
padding: .5em;
}