I have something to this effect:
#div {
background: green;
width: 200px;
height: 100px;
}
h1 {
margin-top: 100px;
}
(And obviously there is some HTML to go with it.)
Now when viewed in the browser the h1
shows at the very top of the #div
and the 100px
margin goes on top of the #div
.
Can anyone suggest a reason?
(The code is a little too complicated to insert the relevant parts so if no-one can give me an answer then I will post it and maybe someone will spot an error or something.)
This is not related to the H1 tag. This is what we call margin collapse.
You can find a post about this subject here : http://reference.sitepoint.com/css/collapsingmargins
you have several solutions :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With