Vertical Stretch Flexbox Test

by jscheel

HTML

<div id="wrapper">
    <div id="inner">
        <div id="content">
            <p>Inner</p>
        </div>
    </div>
    <div id="footer">
        <p>Footer</p>
    </div>
</div>

CSS

#wrapper {
    display: -webkit-box !important;      /* OLD - iOS 6-, Safari 3.1-6 */
      display: -moz-box !important;         /* OLD - Firefox 19- (buggy but mostly works) */
      display: -ms-flexbox !important;      /* TWEENER - IE 10 */
      display: -webkit-flex !important;     /* NEW - Chrome */
      display: flex !important;             /* NEW, Spec - Opera 12.1, Firefox 20+ */
      min-height: 100vh;
      -webkit-flex-direction: column;
      -ms-flex-direction: column;
      flex-direction: column;
      box-sizing: border-box;
    background: #ff0000;
}

#inner {
    -webkit-box-flex: 1;      /* OLD - iOS 6-, Safari 3.1-6 */
      -moz-box-flex: 1;         /* OLD - Firefox 19- */
      width: 100%;              /* For old syntax, otherwise collapses. */
      -webkit-flex: 1;          /* Chrome */
      -ms-flex: 1;              /* IE 10 */
      flex: 1;                  /* NEW, Spec - Opera 12.1, Firefox 20+ */
    background: #0000ff;
    text-align: center;
}

#content {
    min-height: 400px;
    background-color: #ff0000;
}

#footer {
    background: #00ff00;
    padding: 20px;
    text-align: center;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>

JavaScript

$(document).ready(function(){
    var interval = setInterval(function(){
        var top = parseInt($('#footer').height(), 10);
        if (top > 260) {
            clearInterval(interval);
        }
        else {
            $('#footer').css('height', top + 20);
        }
    
}, 350);
});