CSS only Sticky Footer demo

Footer stays at bottom of viewport unless content pushes it down.

by zeroskillz

HTML

<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/black-tie/jquery-ui.css">
<header>
    <h4>Sticky footer demo</h4>
</header>

<div class="content">
    <p>Adjust slider to increase size of content</p>
    <div id="slider"></div>
</div>


<footer>
    <h4>Footer</h4>
</footer>

CSS

*{
    box-sizing:border-box;
}

html
{
    margin:0;
    padding:0;
    height: 100%;
}
  
body
{
    margin:0;
    min-height: 100%;
    position: relative;
    padding: 0 0 110px 0;/*height of footer + a little space*/
}
footer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height:100px;
  margin-bottom: 0;
  background-color: #cccccc;
  padding:10px;
}

/***************************/
header{
    margin:0; padding:10px;
}

html, body{
    font-family:sans-serif;
}
.content{
    padding:10px 20px;
    background:#efefef;
    min-height:84px;
}

JavaScript

// this is just for the demo
$(function() {
    $( "#slider" ).slider({
          slide: function( event, ui ) {
              $('.content').height((ui.value*10) + 80);
          }
    });
});