I have very specific request for centering elements so I decided to try flexbox.
The request is following. I have 3 elements stacked vertically.
Header, content and footer.
A special condition is there to have middle element "content" centered on page (vertically and horizontaly) and header with footer stick on it from top and down. It should works with window resize. There is hard-coded solution for better demonstration. http://codepen.io/anon/pen/oXjVmE
I tried to solve that with flex box, but only what I get is that all 3 elements are centered together.
I am looking how to tell flex-box "First and last element should be same and max possible height" http://codepen.io/anon/pen/GJpeYY
html
<div class="wrapper">
<div class="header">
<h1>Header</h1>
<h2>Subheader</h2>
<p>Text</p>
</div>
<div class="centered">
Centered Text
</div>
<div class="footer">
Some tiny footer
</div>
</div>
css
.wrapper {
height:500px;
background-color:lightgreen;
.display(flex);
.flex-direction(column);
.align-items(center);
.justify-content(center);
text-align: center;
}
.header {
background-color:gold;
}
.centered {
height: 50px;
line-height: 50px;
background-color:deepskyblue;
}
.footer {
background-color:tomato;
}