0

I am attempting to finish my header, but there is a massive space between the top of the page and the header. I would like to keep my image in place but the header at top but the same size. Here is my code:

HTML

<div id="header_logo-clearfix">
    <div id="header_logo"><a href="file:///C:/Users/Swag/Desktop/My%20Website/Home/home.html"><div id="logo"><img src="Header/banner.png" alt="Logo" align="middle" width="300"height="100"></a>
    </div>
</div>

CSS

 #header_logo-clearfix {
    width: 100%;
    height: 180px;
    margin: 0;
    padding: 0;
    display: block;
    background-color: #02236a;
}

#header_logo {
    margin-left: auto;
    margin-right: auto;
    width: 20%;
    margin-top: 40px;
}

JSFiddle.

ieblake
  • 74
  • 1
  • 12

3 Answers3

1

It is because of #header_logo { has margin-top: 40px; Just remove it will solve your issue.

Edit:

Add padding-top:40px; instead will down your image.

Check Fiddle.

New updated CSS:

#header_logo-clearfix {
  width: 100%;
  height: 180px;
  margin: 0;
  padding: 0;
  display: block;
  background-color: #02236a;
}

#header_logo {
  margin-left: auto;
  margin-right: auto;
  width: 20%;
    padding-top: 40px;
}
ketan
  • 19,129
  • 42
  • 60
  • 98
0

You have a missing <div> tag here

<div id="logo"><img src="Header/banner.png" alt="Logo" align="middle" width="300"height="100">

The div with id "logo" does not have a corresponding end tag. I am not sure if that will fix the issue but it can definitely give you unexpected behavior in lower end browsers that are not capable of auto matching missing HTML tags.

Diptendu
  • 2,120
  • 1
  • 15
  • 28
0

Remove the marrgin-top: 40px from #header_logo class

check thisfiddle

Jackson
  • 149
  • 6