I have a margin-top: 50px
set to the .greeting class div, which is basically the big greeting image. But for whatever reason, it drags down the previous nav element for some reason, even though they’re not attached.
On my main site, http://christianselig.com, I have it (without WordPress implementation), so I’m confused what’s different here.
Used to this css clear your header
id
Result is
Margin Collapse
As a gross oversimplification:
The
#masthead
is collapsing since all of its’ children (in this case only one) are floating, and therefore losing it’s layout properties.Add this:
Alternatively, remove the
float
property in your.main-navigation
rule and replace it withoverflow: hidden;
instead. I don’s see a reason why this should be floating anyways.It’s caused by collapsing margins, but it’s somewhat unintuitive because the margin of your main content is collapsing with the
<header>
element above it. This happens because your header (#masthead
) is ending up with zero-height. To correct this, just addoverflow:hidden
to the#masthead
header element.That will cause #masthead to expand to include the floated
nav
element it contains, which in turn will prevent the margin from collapsing onto the #masthead header.