Today I was trying to make a form (in this case it's a div with class .second-div
) under another div with this code:
.first-div
{
width: 25%;
height: 100px;
float: right;
position: relative;
background-color: blue;
margin-top: 2.5em;
margin-right: 2em;
}
.second-div
{
width: 80%;
height: 100px;
margin: 60px auto 60px auto;
position: relative;
background-color: red;
clear: both;
}
<div class="first-div"></div>
<div class="second-div"></div>
My question is, why doesn't this CSS apply margin-top to the .second-div
and both of these divs are tied together? What's even stranger to me is that when I apply margin-bottom to the .first-div
, it works as I'd like it to. Can someone explain this to me?