force footer on bottom on pages with little content

This Flexbox solution is neater and far easier to implement:

HTML

<body>
  <div class="content">
    content
  </div>
  <footer class="footer"></footer>
</body>

CSS

html, body {
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
}
.content {
  flex: 1 0 auto;
}
.footer {
  flex-shrink: 0;
}

Just ensure you wrap the necessary divs inside the body.

Leave a Comment