Check out example codes for "center div vertically css". It will help you in understanding the concepts better.

Code Example 1

div
{
	display: block;
	margin-left: auto;
	margin-right: auto;
	width: 40%;
}

Code Example 2

<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>

Code Example 3

/* No Flexbox */
.parent {
  position: relative;
}
.child {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

/* With Flexbox */

.parent {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

Code Example 4

.center {
  display: flex;
  justify-content: center;
  
  align-items: center;
  height: 200px;
  border: 3px solid 
  green; 
}

Code Example 5

.container{
  display: table;
}

.div-inside-container{
  display: table-cell;
  vertical-align: middle;
}

Learn ReactJs, React Native from akashmittal.com