26

http://cdpn.io/FykHr I seem to have an issue with the combined CSS properties:

position: absolute;
bottom: 0;

First you can see that the .footer div doesn't isn't at the bottom. Now, change the font-size from 120px to 50px and the div seems to be working the way I inteded it to.

How do I make the .footer div stay at the bottom (not fixed at the bottom of the screen) regardless of the size of the .content div.

Harrison Tran
  • 1,571
  • 3
  • 13
  • 26
  • On my Firefox, codepen website (not your code) doesn't work. On Chromium your code works and I can't reproduce your problem. – Oriol Oct 26 '13 at 23:26

2 Answers2

50

You need to add position: relative; to the parent container, which in this case is .wrapper.

Here's a good reference page on absolute positioning.

keirog
  • 2,158
  • 1
  • 19
  • 17
  • 3
    Worked for me. Was having trouble getting a modal window to stretch to the bottom of the page. Set `position: relative` on the `` tag and magic. – kmgdev Feb 12 '14 at 23:47
  • 10-years later and still saving the day @keirog! Worked for me. I develop in Ruby on Rails and something in one of my gems (either Bootstrap or the like) changed and all of a sudden a rounded buttom of my nav section was being sent to the bottom of the webpage. When I apply this answer to the parent container "navbar", everything works as expected. – CWarrington Mar 14 '23 at 02:40
11

There is one way to do that:

body {
    height: 100%;
    margin: 0;
}
html {
    padding-bottom: 50px;
    min-height: 100%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    position: relative;
}

footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background-color: red;
}

http://jsfiddle.net/n8UNM/

There is still one limitation. You have to know height of footer and set it in two places.