I'm trying to play with positioning in css and I noticed something that confused me. It's probably a dumb question...but I'm having trouble understanding it.
I created three divs with the width and height of 50px with different background colors. When I position the third div up -60px using margin-top, the third div is on top of the second div. However, when I make the first and second divs inline elements, then both the first two divs are now on top of the third one.
Can someone please explain this concept to me?
<head>
 <style>
    <!-- Divs with the same width and height. Second one where both the first two divs are inline below this one. -->
    #one{
    background-color:red;
    width:50px;
    height:50px;  
     }
    #two{background-color:blue;
    width:50px;
    height:50px; 
     }
    #three{background-color:green;
    width:50px;
    height:50px;
    margin-top:-60px; 
     }
 </style>
</head>
<body>
  <div id="one">
  </div>
  <div id="two">
  </div>
  <div id="three">
  </div>
</body>
<head>
 <style>
    <!-- First two divs are inline  -->
    #one{
    background-color:red;
    width:50px;
    height:50px;  
     }
    #two{background-color:blue;
    width:50px;
    height:50px; 
     }
    #one, #two{display:inline-block;}
    #three{background-color:green;
    width:50px;
    height:50px;
    margin-top:-60px; 
     }
 </style>
</head>
<body>
  <div id="one">
  </div>
  <div id="two">
  </div>
  <div id="three">
  </div>
</body>
 
     
    