导航栏无法正确渲染

时间:2015-01-23 21:34:21

标签: html css

我的导航栏似乎比我的其他页面停止的地方延伸得更远。在JSfiddle中查看我的代码,了解here发生了什么。我似乎无法弄清楚为什么会这样。

HTML:

<div id="header-wrapper">
            <center>
                <a href="index.html" id="logo"><img src="images/logo.png" alt=""/></a>
            </center>
            <div class="container">
                <div class="row">
                    <div class="12u">
                        <header id="header">
                            <nav id="nav">
                                <a href="index.html" class="current current-page-item"><i class="fa fa-home"></i>&nbsp Home</a>
                                <a href="#"><i class="fa fa-flag-o"></i>&nbsp RFP Recap '14-'15</a>
                                <a href="#"><i class="fa fa-database"></i>&nbsp Archived Updates</a>
                                <a href="#"><i class="fa fa-phone"></i>&nbsp Contact Us</a>
                                <a href="#"><i class="fa fa-folder-open-o"></i>&nbsp Member Contacts</a>
                                <a href="#" target="_blank"><i class="fa fa-sign-in"></i>&nbsp Log In</a>
                            </nav>
                      </header>
                    </div>
                </div>
            </div>
        </div>

CSS:

/* Header */

    #header-wrapper {
        background-color: #007294;
        background-image: -moz-linear-gradient(top, #008dab, #007294);
        background-image: -webkit-linear-gradient(top, #008dab, #007294);
        background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008dab), to(#007294));
        background-image: -ms-linear-gradient(top, #008dab, #007294);
        background-image: -o-linear-gradient(top, #008dab, #007294);
        background-image: linear-gradient(top, #008dab, #007294);
    }

    #header {
    position: relative;
    border-radius: 10px;
    border: solid 1px #006e8b;
    box-shadow: inset 0px 0px 0px 1px #12a0bf, 0px 1px 4px 0px rgba(0,0,0,0.10);
    background-color: #007b9d;
    background-image: -moz-linear-gradient(top, #008ead, #007b9d);
    background-image: -webkit-linear-gradient(top, #008ead, #007b9d);
    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008ead), to(#007b9d));
    background-image: -ms-linear-gradient(top, #008ead, #007b9d);
    background-image: -o-linear-gradient(top, #008ead, #007b9d);
    background-image: linear-gradient(top, #008ead, #007b9d);
    height: 86px;
    width: 1200px;
    margin-top: 0%;
    margin-right: 0;
    margin-bottom: 2.5%;
    margin-left: 0;
    padding-top: 0;
    padding-right: 0px;
    padding-bottom: 0;
    padding-left: 0px;
    }

        #header h1 {
    position: absolute;
    left: 0px;
    top: 10px;
    color: #fff;
    font-size: 2.4em;
    letter-spacing: -2px;
    line-height: 86px;
        }

        #header h1 a {
            color: #fff;
            text-decoration: none;
        }

        #header nav {
    position: absolute;
    right: 40px;
    top: 1px;
    line-height: 84px;
    text-transform: ;
    font-size: 1.3em;
    letter-spacing: -1px;
    width: 1066px;
    height: 92px;
        }

            #header nav a {
                display: inline-block;
                text-decoration: none;
                color: #fff;
                padding: 0 25px 0 25px;
                outline: 0;
            }

            #header nav a.current-page-item {
                background-color: #007897;
                background-image: -moz-linear-gradient(top, #007b99, #007897);
                background-image: -webkit-linear-gradient(top, #007b99, #007897);
                background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#007b99), to(#007897));
                background-image: -ms-linear-gradient(top, #007b99, #007897);
                background-image: -o-linear-gradient(top, #007b99, #007897);
                background-image: linear-gradient(top, #007b99, #007897);
                box-shadow: inset 0px 1px 5px 1px rgba(0,0,0,0.1), 0px 0px 5px 1px rgba(255,255,255,0.1);
            }

            #header nav a:hover {
                background-color: #0882a1;
                background-image: -moz-linear-gradient(top, #0782a0, #077d9b);
                background-image: -webkit-linear-gradient(top, #0782a0, #077d9b);
                background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0782a0), to(#077d9b));
                background-image: -ms-linear-gradient(top, #0782a0, #077d9b);
                background-image: -o-linear-gradient(top, #0782a0, #077d9b);
                background-image: linear-gradient(top, #0782a0, #077d9b);
                box-shadow: inset 0px 1px 5px 1px rgba(0,0,0,0.05), 0px 0px 5px 1px rgba(255,255,255,0.05);
            }

2 个答案:

答案 0 :(得分:1)

第80行中缺少css的值:

  text-transform: ;

加上html实体,如$ nbsp;最后$nbsp;

答案 1 :(得分:1)

将body标签设置为:

body{
position:relative;
margin:0 auto;
width:1200px;
}

接下来给#header-wrapper&amp; #header WIDTH为100%

 #header-wrapper,#header{
 width:100%;
 }

这应该让你的#header保持在你的Wrapper中,并且Wrapper应该保留在你的身体内。

/ == TAB TEXT == /

尝试用此

替换#header nav a
 #header nav a {
 float:left; <!-- Changed from display:inline-block; -->
 text-decoration: none;
 color: #fff;
 padding: 0px 0px 0px 10px; <!-- changed from  0px 25px 0px 25px-->
 outline: 0;
 }