页面顶部的页眉空白

时间:2015-10-21 17:52:19

标签: html css html5 css3 header

我的问题是我的标题与我的页面顶部略有分离,我似乎无法弄清楚原因,它可能非常简单,但我迷失了。任何人都可以帮我把它恢复到页面顶部吗?

提前多多感谢。

继承代码,

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;
}

对这个论坛有点新意,对格式错误的帖子表示道歉,希望你能说出来,我非常感谢任何帮助,非常感谢。

杰克。

3 个答案:

答案 0 :(得分:1)

您可以使用...

来解决这个问题
top: 0;

当您在该元素上使用固定位置时。

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

in action on JSFiddle

答案 1 :(得分:0)

将{{1}}添加到CSS

答案 2 :(得分:0)

发生这种情况的主要原因是因为bannerposition:fixed,我认为有一个原因也是固定的,但是如果没有,你可以删除它,它也会解决你的问题。