CSS Layout How to - Stick footer to bottom with position: absolute;








Question

We would like to know how to stick footer to bottom with position: absolute;.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#Navbar {<!--   w w  w  . j  ava2 s.  c  o  m-->
  display: block;
  overflow: hidden;
  width: 100%;
  height: 64px;
  position: absolute;
  bottom: 15px;
}

#Buttonbar {
  display: block;
  overflow: hidden;
  padding: 0px;
  width: 400px;
  height: 100%;
  margin: 0px auto 0px auto;
  background: #EEE;
}

#Buttonbar>li {
  display: block;
  float: left;
  overflow: hidden;
  list-style: none;
  padding: 0px;
  margin: 0px;
}
</style>
</head>
<body>
  <nav id="Navbar">
    <ul id="Buttonbar">
      <li>Link</li>
      <li>Link #2</li>
      <li>Link</li>
      <li>Link #2</li>
      <li>Link</li>
      <li>Link #2</li>
      <li>Link</li>
      <li>Link #2</li>
      <li>Link</li>
      <li>Link #2</li>
    </ul>
  </nav>
</body>
</html>

The code above is rendered as follows: