HTML Element Style How to - Vertical Alignment of Div








Question

We would like to know how to vertical Alignment of Div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.parentPanel {<!-- w  w w. j  av  a2  s.  c om-->
  border: 1px solid blue;
}

.content {
  border: 1px solid blue;
  display: inline-block;
  vertical-align: middle;
}

.content img {
  display: block;
}

.sidebar {
  border: 1px solid blue;
  display: inline-block;
  vertical-align: middle;
}
</style>
</head>
<body>
  <div class="parentPanel">
    <div class="content">
      <img src="http://placehold.it/400x500">
    </div>
    <div class="sidebar">
      <ul>
        <li>Homepage</li>
        <li>blah</li>
        <li>blah</li>
        <li>blah</li>
        <li>blah</li>
        <li>blah</li>
        <li>blah</li>
        <li>blah</li>
      </ul>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: