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

Code Example 1

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

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

div.center{display:block;margin:auto;width:50%;}
p.center{text-align:center;}

Code Example 4

.parent-class {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

Code Example 5

.center
{

  margin: auto;

   
width: 50%;

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

}

Code Example 6

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

Learn ReactJs, React Native from akashmittal.com