0

我的标题部分有点混乱。我的导航菜单被放在实际标题下方。我尝试将显示更改为内联,但是当我对#navmenu 执行此操作时,它会清除颜色并完全保持不变。

我知道对于我提出的几乎所有问题可能都有一个简单的答案,但是有人可以帮助我吗?

HTML:

<!DOCTYPE html>

<html>

    <head>
        <meta name="Description" content="This is your test website!"/>
        <meta name="author" content="Me!"/>
        <title>ReallyGoodPie | Home</title>
        <link type="text/css" rel="stylesheet" href="css/style.css"/>
    </head>

    <body>

        <div id="wrapper">
            <nav id="navmenu">
            <div id="title">
                <h1>Title</h1>
            </div>

                <ul>
                    <li>Home</li>
                    <li>About</li>
                    <li>Tutorials</li>
                    <li>Services</li>
                    <li>Contact Us</li>
                </ul>
            </nav>

            <aside id="sidenews">

            </aside>

            <div id="center">

                <section id="mainsection">
                    <article>
                        <header>
                            <hgroup>
                                <h1>This is a test</h1>
                                <h2>I like tests!</h2>
                            </hgroup>
                        </header>
                        <section>
                            <p>This is the main section of my section (sectception)</p>
                        </section>
                        <footer>
                            <p>Time and date</p>
                        </footer>
                    </article>
                </section>

            </div>

            <footer id="cright">
                <p>This is the copyright section. All rights reserved.</p>
            </footer>
    </body>

</html>

CSS:

*{
margin: 0;
padding: 0;
}

header, section, footer, aside, nav, article, hgroup{
    display: block;
}

a{
    text-decoration: none;
    color: #FFF;
}

a:hover{
    color: #333399;
}


#wrapper{
    width: 100%;
    margin: 20px auto;
    margin-top: 0px;
    text-align: left;
    background-color: #FFF;
}

#navmenu{
    background: #3366CC;
    color: #eee;
    text-align: right;
    height: 100px;
    padding: 0;
    margin:0;
    float: top;
    width: 100%;
}

#navmenu li{
    display: inline-block;
    list-style: none;
    padding: 20px;

}

#navmenu ul{
    padding-right: 10px;
}

#navmenu li:hover{
    color: #FFF;
    background: #3399FF;
    border-radius: 5px;
    -moz-border-radius: 5px;
    padding-top: 10px;
    padding-bottom: 10px;
}




#mainsection{
    float:left;
    width: 630px;
    margin:30px;
    margin-top: 2
    background-color:#FFF;
    color: #222;
    text-align: left;

}

#cright{
    text-align:center;
    background-color: #AAA;
    clear: both;
}

#center{
    width: 1000px;
    height: 1000px;
    background-color:#FFF;
}

#sidenews{
    float:right;
    width: 250px;
    height: 940px;
    margin: 0px 0px;
    padding: 30px;
    background-color:#FFF;
}

#title{
    text-align: left;
    padding: 0;
    padding-top: 10px;
    padding-left: 10px;
    width: 200px;
}

h1{
    width: 100px;
}
4

3 回答 3

2

如果我理解您的“问题”,您希望标题位于导航的左侧吗?在这种情况下,您需要使用:

#title
{
    float: left;
}

http://jsfiddle.net/z3F4x/

于 2013-02-09T10:30:32.873 回答
0

将 float 属性设置为 onnavmenu ultitletoleft

#title{
    text-align: left;
    padding: 0;
    padding-top: 10px;
    padding-left: 10px;
    width: 100px;
    float: left;
}

#navmenu ul{
    padding-right: 10px;
    float:left;
}

工作示例:http: //jsfiddle.net/J5Zvn/

于 2013-02-09T10:31:09.867 回答
0

如果你想把你的标题移到导航菜单之外,如果你想在上面,或者如果你想在下面

          <div id="wrapper">
          <div id="title">
                    <h1>Title</h1>
                </div>
            <nav id="navmenu">

                <ul>
                    <li>Home</a>
                    <li>About</li>
                    <li>Tutorials</li>
                    <li>Services</li>
                    <li>Contact Us</li>
                </ul>
于 2013-02-09T10:33:18.710 回答