CSS Property Value How to - display: table-cell; Align middle table-cell and vertical








Question

We would like to know how to display: table-cell; Align middle table-cell and vertical.

Answer


<!--  w ww  . j  a  va 2  s .  c o m-->
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.container {
  display: table;
  height: 100px;
}

.panel {
  display: table-cell;
  vertical-align: middle;
  border: 1px solid red;
}
</style>
</head>
<body>
  <div class="container">
    <div class="panel">hey</div>
    <div class="panel">hey</div>
  </div>
</body>
</html>

The code above is rendered as follows: