Check out example codes for "css z index". It will help you in understanding the concepts better.

Code Example 1

#nav {
  position: fixed;
  ...
  z-index: 2;
}
#main {
  position: absolute;
  ...
  z-index: 1;
}

Code Example 2

img
 {

     
 position: absolute;

     
 left: 0px;

     
 top: 0px;

     
 z-index: -1;

 }

Code Example 3

img {
  position: absolute; 
  /*position: relative;
  //position: fixed;*/
  left: 0px;
  top: 0px;
  z-index: -1;
}

The z-index property specifies the stack order of an element.

An element with greater stack order is always in front of an element with a lower stack order.

Note: z-index only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky).

Code Example 4

the default z-index is 0.

Code Example 5

z-index

Learn ReactJs, React Native from akashmittal.com