I'm trying to achieve this layout in the latest Chrome, Firefox and IE11:
I can get this working with the following:
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
html, body { height: 100%; padding: 0; margin: 0; }
p { line-height: 2em; }
header, footer, article { padding: 10px; }
#parent {
height: 100%;
display: flex;
flex-flow: column nowrap;
background-color: limegreen;
}
#parent > header {
flex: none;
background-color: limegreen;
}
#parent > footer {
flex: none;
}
#child {
display: flex;
flex-direction: column;
background-color: red;
height: 100%;
min-height: 0;
}
#child > header {
flex: none;
background-color: #aaa;
}
#child > article {
flex: 1 1 auto;
overflow-y: auto;
min-height: 0px;
}
#child > footer {
flex: none;
background-color: #aaa;
}
<section id="parent">
<header>Parent flex header </header>
<section id="child" >
<header>Child flex header</header>
<article>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
<p>Lots of content.</p>
</article>
<footer>Child flex footer</footer>
</section>
<footer>Parent flex footer</footer>
</section>
However some of the CSS I find a bit strange and I want to make sure that I have the most chance to not produce CSS that will break in some browser update. The reason for this is that the software will run on actual hardware (kind of like your router admin interface) and cannot be updated as easily as a regular website.
So the CSS that kind of troubles me is the scrollable article
:
#child {
display: flex;
flex-direction: column;
background-color: red;
height: 100%;
min-height: 0;
}
I fiddled around with the height
and min-height
to make it work in all three. Originally I had height: 100%
only, but that didn't work in Firefox. Specifying min-height: 0
would work in Chrome and FF, but not in IE. The combination seemed to satisfy all 3, but who is correct? Can I be reasonably sure that this wont break in the next FF or Chrome? Does this code make sense from a 'spec-perspective'?