Jack Wigham
Jack Wigham

Reputation: 17

Header gap at top of page

my problem is that my header is slightly separated from the top of my page and I can not seem to figure out why, it could be really simple but i'm lost. Could anyone help me with getting it back to the top of the page?

Thanks a lot in advance.

Heres the code,

HTML:

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>stepps</title>
    <link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>

    <div class="container">

        <header>
            <img src="images/logo.png">


            <nav>
                <ul>
                    <li><a href="#">Home</a></li>
                    <li><a href="#">About</a></li>
                    <li><a href="#">Members</a></li>
                    <li><a href="#">Productions</a></li>
                    <li><a href="#">Gallery</a></li>
                    <li><a href="#">Tickets</a></li>
                    <li><a href="#">FAQ</a></li>
                    <li><a href="#">Contact Us</a></li>
                </ul>
            </nav>
        </header>

        <div id="banner">


        </div>

        <div id="content">
            <p>Bacon ipsum dolor amet pastrami tail pork, cupim pig porchetta swine pork chop leberkas flank sausage beef ribs. Bresaola venison andouille fatback capicola kevin. Pancetta ham meatball venison cupim rump, drumstick beef picanha turkey. Chicken filet mignon hamburger strip steak venison, doner cow beef ribs boudin brisket salami landjaeger biltong ham shankle. Filet mignon doner kevin, spare ribs cupim corned beef porchetta hamburger drumstick leberkas. Frankfurter pastrami sirloin jerky rump sausage ball tip strip steak landjaeger jowl ground round chuck cow kielbasa hamburger. Turducken bacon alcatra bresaola ball tip meatloaf.

Ham chicken shankle bresaola. Bresaola swine andouille kielbasa, short ribs filet mignon pastrami boudin pork loin jerky turducken ham hock. Meatloaf salami prosciutto, bresaola tail jerky alcatra filet mignon rump. Alcatra shankle boudin pork belly, pork kielbasa ball tip sirloin brisket bresaola turducken tenderloin. Salami shoulder corned beef strip steak, spare ribs fatback drumstick tenderloin. Chuck prosciutto andouille, tongue frankfurter capicola venison tri-tip shank kielbasa chicken.

Ground round tri-tip shoulder, pig turkey doner andouille turducken corned beef jowl leberkas sausage biltong picanha. Leberkas chuck strip steak, beef beef ribs bresaola ribeye short ribs meatloaf pastrami pig corned beef drumstick. Kevin andouille swine corned beef beef frankfurter cupim capicola flank porchetta alcatra chuck. Pork belly tri-tip chuck jowl, beef drumstick brisket cupim andouille turkey sirloin strip steak tongue. Pork loin tenderloin sausage, meatball meatloaf pastrami chicken short loin turducken biltong jerky t-bone landjaeger tri-tip rump. Meatloaf sausage salami t-bone leberkas capicola flank ham hock pork belly pork chop. Pork beef hamburger salami fatback biltong alcatra ham drumstick filet mignon tri-tip.</p>
        </div>

    </div>
</body>
</html>

CSS:

body {
    margin: 0;
    padding: 0;
    border: 0;
    font-family: 'Helvetica';
    background-color: #E6E6E6;
}


header {
    margin: 0;
    padding: 0;
    border: 0;
    height: 110px;
    width: 100%;
    position: fixed;
    background-color: #a43131;
    z-index: 99;
}

header img {
    display: block;
    height: 100px;
    position: relative;
    left: 55%;
    margin-left: -100px;
    padding-top: 5px;
    padding-bottom: 5px;

}




/*navigation */
nav {
    background-color: #7c2828;
    margin: 0;
    font-size: 15px;
    text-align: center;
}

nav ul {
    margin: 0;
    padding: 0;
    display: inline-block;
}

nav ul li {
    /* allows to arrange list items in a row without float */
    display: inline-block;
    list-style-type: none;
}

/* first level items style */
nav > ul > li > a {
    color: #fff;
    background-color: #7c2828;
    display: block;
    line-height: 2em;
    padding: 0.5em 0.5em;
    text-decoration: none;

}


nav > ul > li > a:hover {
    color: #fff;
    background-color: #a43131;
    display: block;
    line-height: 2em;
    padding: 0.5em 0.5em;
    text-decoration: none;
    transition: 0.5s;

}

/* navigation end */


#banner {
    width: 100%;
    height: 800px;
    position: fixed;
    top: 110px;

    background-image:url(images/headerimage.jpg);
    background-size: cover;
}


#content {
    width: 100%;
    position: relative;
    top: 910px;
    background: #e6e6e6;
    height: 1500px;
}

Kind of new to this forum so apologies for the poorly formatted post, hopefully you can make it out, I really appreciate any help, thanks a lot.

Jack.

Upvotes: 0

Views: 2804

Answers (3)

Wiafe
Wiafe

Reputation: 84

The main reason this is happening is because of banner being position:fixed, I assume there is a reason that is also fixed, but if there isn't you can remove that and it will also fix your problem.

Upvotes: 0

Viktor Maksimov
Viktor Maksimov

Reputation: 1465

Add header { top: 0; } to the CSS

Upvotes: 0

Fenton
Fenton

Reputation: 250972

You can fix that using...

top: 0;

As you are using a fixed position on that element.

header {
    margin: 0;
    padding: 0;
    border: 0;
    height: 110px;
    width: 100%;
    position: fixed;
    top: 0;
    background-color: #a43131;
    z-index: 99;
}

See it in action on JSFiddle.

Upvotes: 1

Related Questions