CSS Layout How to - Vertical align to bottom








Question

We would like to know how to vertical align to bottom.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#container {<!--from   ww w  .  j a va2  s. com-->
  height: 300px;
  border: 1px solid;
  padding: 5px;
  display: table-cell;
  vertical-align: bottom;
}

.message {
  border: 1px solid;
  margin-top: 5px;
}
</style>
</head>
<body>
  <p>Top of page</p>
  <div id="container">
    <div class="message">Message 4</div>
    <div class="message">Message 3</div>
    <div class="message">Message 2</div>
    <div class="message">Message 1</div>
  </div>
  <p>Bottom of page</p>
</body>
</html>

The code above is rendered as follows: