Bootstrap Tutorial - Align to vertical center








The following code shows how to align to vertical center.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type='text/javascript'
  src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.1.0/bootstrap.min.js"></script>
<style type='text/css'>
@import<!-- w w  w . j  a  v  a  2 s  . c  om-->
  url('http://twitter.github.com/bootstrap/assets/css/bootstrap.css');

.container {
  margin-top: 10px;
}

.span6:first-child {
  line-height: 300px;
}

.span6 {
  line-height: 170px;
}
</style>
</head>
<body>
  <div class="container">
    <div class="row" style="display: table">
      <div class="span6"
        style="height: 300px; background: red; display: table-cell !important; vertical-align: middle;">
        Block 1 - Vertically center me please!</div>
      <div class="span6"
        style="height: 170px; background: blue; display: table-cell !important; vertical-align: middle;">
        Block 2- Center me too</div>
    </div>
  </diV>
</body>
</html>

Click to view the demo