CSS Property Value How to - vertical-align: middle;








Question

We would like to know how to vertical-align: middle;.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#main {<!--from w  w w  . java 2 s .  c om-->
  outline: 1px solid blue;
  height: auto;
  line-height: 400px;
  text-align: center;
}

#main .top {
  vertical-align: top;
}

#main .mid {
  vertical-align: middle;
}

#main .bot {
  vertical-align: bottom;
}
</style>
</head>
<body>
  <div id="main">
    <img class="mid"
      src="http://www.java2s.com/style/download.png"
      width="100" height="100" />
  </div>
</body>
</html>

The code above is rendered as follows: