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

Code Example 1

.center
{

  margin: auto;

   
width: 50%;

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

}

Code Example 2

/* html */
<h1>Centering with CSS</h1>

<h3>Text-Align Method</h3>
<div class="blue-square-container">
  <div class="blue-square"></div>
</div>

<h3>Margin Auto Method</h3>
<div class="yellow-square"></div>

<h3>Absolute Positioning Method</h3>
<div class="green-square"></div>

/* css */
h1,
h3 {
  text-align: center;
}

.blue-square-container {
  text-align: center;
}

.blue-square {
  background-color: #0074D9;
  width: 100px;
  height: 100px;
  display: inline-block;
}

Code Example 3

.container {
  display: flex;
  justify-content: center;
  align-items: center;
}

Code Example 4

# center text
.center {
  text-align: center;
  
border: 3px solid green;
}

Code Example 5

.parent {
  position: relative;
}
.child {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

Code Example 6

<style>
.content {
  max-width: 500px;
  
  margin: auto;
}
</style>

  <body>

<div class="content">
  <!-- Page content -->
</div>

</body>

Learn ReactJs, React Native from akashmittal.com