导航菜单位置不正确

有点奢侈

似乎找不到导航菜单布局的问题...它不在div容器的中心。顺便说一句,它不是原始菜单,而是纯CSS菜单,最初没有图形,但存在相同的问题。由于我找不到错误所在,因此我举了一个有效的示例,但在代码中包含了同样的问题。

请帮助...谢谢。

在此处输入图片说明

    <html>
<head>
<title>Home</title>
</head>
<link href="home.css" rel="stylesheet" type="text/css" />

<script src="js/jquery-1.11.0.min.js"></script>

<body>
<div id="container">
    <div class="header-cont">
        <div class="header">
            <img src="images/header.png"></img>
            <?php   require ("testnavigation.php"); ?>
        </div>
    </div>

    <div id="content-container1">


        <div id="section-navigation">
            <p>sidebar navigation</p>
        </div>
        <div id="content">
            <p>contents here</p>
        </div>

        <div id="aside">
            <h3>Aside heading</h3>
            <p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit
                esse molestie consequat, vel illum dolore eu feugiat nulla
                facilisis at vero eros et accumsan.</p>
        </div>
        <div id="footer">Copyright © Site name, 20XX</div>
    </div>
</div>
</body>
</html>

这是CSS

body {
    //font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, Sans-Serif;
    //font-size: 12px;
    background: #0E2B43;
}

.header-cont {
    width: 100%;
    position: fixed;
    top: 0px;
    left: 0px;
}

.header > img {
    horizontal-align: middle;
  vertical-align: middle;
}

.header {
    height: 122px;
    background: #333;
    //border: 1px solid #CCC; 
    width: 100%;
    margin: 0px auto;
}

#container {
    margin: 0 auto;
    width: 100%;
    //width: 966px;
    background: #33FF99;
}

#header h1 {
    margin: 0;
}

#content-container1 {
    float: left;
    width: 100%;
    background-color: #e9eaed;
    margin: 122px auto;
}

#content-container2 {
    float: left;
    width: 100%;
}

#content {
    float: left;
    width: 40%;
    padding: 20px 0;
    margin: 0 0 0 2%;
}

#content h2 {
    margin: 0;
}

#aside {
    float: right;
    width: 35%;
    padding: 20px 0;
    margin: 0 2% 0 0;
    display: inline;
}

#aside h3 {
    margin: 0;
}

#footer {
    clear: both;
    background: #ccc;
    text-align: right;
    padding: 20px;
    height: 1%;
}

#content h1 { //
    margin: 1em 0 0.5em 0;
    color: #343434;
    font-weight: normal;
    font-size: 30px;
    line-height: 40px; //
    font-family: 'Orienta', sans-serif;
    border-bottom: 1px solid rgba(53, 86, 129, 0.3);
}

/* These are used on the sidebar */
#section-navigation {
    float: left;
    width: 16%;
    padding: 20px 0;
    margin: 0 2%;
    display: inline; //
    background-color: #ccc;
}

#section-navigation ul {
    margin: 0;
    padding: 0;
}

#section-navigation ul li {
    margin: 0 0 1em;
    padding: 0;
    list-style-type: none;
}

#section-navigation li a {
    display: block;
    margin: 0 0px 0 0;
    width: auto;
    text-decoration: none;
}
/* These are used on the sidebar */

/* These are used on the header navigation */
.clearer {
    clear: both;
}

#navigation-row {
    background: #aeb5b8 url("images/navigation-bg.gif") repeat-x left top;
    height: 38px;
    border-left: solid 1px #818b8f;
    border-right: solid 1px #818b8f;
    //width: 920px;
    width: 100%;
    margin: 0px auto;
}

ul#navigation {
    display: block;
    float: left;
    list-style: none;
    background: url("images/nav-spacer.gif") repeat-y -1px top;
    height: 38px;
}

ul#navigation li {
    display: block;
    float: left;
    background: url("images/nav-spacer.gif") repeat-y right top;
    height: 38px;
    padding-right: 2px;
}

ul#navigation li a {
    display: block;
    float: left;
    line-height: 38px;
    padding: 0px 20px;
    font-family: Verdana;
    font-size: 14px;
    color: #313a3e;
    text-decoration: none;
   // text-transform: uppercase;
    letter-spacing: -1px;
}

ul#navigation li a:hover, ul#navigation li a.active {
    background: url("images/nav-bg-hover.gif") repeat-x left top;
}

这是navigation.php

<div id="navigation-row">
    <ul id="navigation">
        <li><a href="Home.php">Home</a></li>
        <li><a href="#">Account</a></li>
        <li><a href="logout.php">Logout</font></a></li>
    </ul>

    <div class="search">
                <form action="search.php" method="POST">
                    <input name="search" type="text" maxlength="30" class="textfield"
                        value="search" />

                </form>
            </div>

        <div class="clearer"></div>
</div>
格特拉蒙蒂娜

我的猜测是您ul#navigation继承了默认用户代理的样式表,该样式表在Chrome中的边距为16px。如果您增加margin: 0;该规则,我想您可能会得到想要的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章