Check out example codes for "css prevent margin collapsing". It will help you in understanding the concepts better.

Code Example 1

/* Some CSS Properties that prevent margin collapsing (each of them does) */

float: left;
float: right;

position: absolute;

display: inline-block;
display: flex;

overflow: hidden;

Learn ReactJs, React Native from akashmittal.com