css div vertical center

CSS
.center
{

  margin: auto;

   
width: 50%;

   
border: 3px solid green;
  padding: 10px;

} <!DOCTYPE html>
<html>
   <head>
      ...
      <style type="text/css">
         div{
         width: 200px;
         height: 200px;
         border: solid green;
         display: table-cell;
         vertical-align: middle;
         }
      </style>
   </head>
   <body>
      <div>Vertikal ausgerichteter Text</div>
   </body>
</html>  <style>
.container { 
  height: 200px;
  position: 
  relative;
  border: 3px solid green; 
}

.center {
  margin: 0;
  
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: 
  translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
</style>

<div 
  class="container">
  <div class="center">
    
  <p>I am vertically and horizontally centered.</p>
  </div>
</div> 
Source

Also in CSS: