<div class="container">
  <p>
    Lets imagine we're building a content box with a sticky
    footer (just for the box, not our whole site). Not that
    this is the only way to do it, but we are using absolute
    positioning for the gray footer. Perhaps we're going to 
    add scrolling to the white content area later.
  </p><p>
    The problem is that
    it hangs over the container. The reason is because of
    <code>width: 100%</code> and box-sizing turned off. Or,
    with or without box-sizing, we can
    do <code>left: 0; right: 0;</code>
  </p>
  <footer>My Footer (with a width of 100%)</footer>
</div>
body {
  background-color: #eee;
  margin: 1em;
}

.container {
  max-width: 500px;
  background-color: #fff;
  padding: 1em;
  padding-bottom: 3em; // offsets footer
  position: relative;
  height: 180px;
}

.container > footer {
  background-color: #444;
  color: #aaa;
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  padding: 1em;
}

.container:hover > footer {
  width: auto;
  right: 0;
}

// Note that the only reason why I don't have the box-sizing as appart of my reset, is so I can toggle it with hover.
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.