0

我一直在研究一个下拉导航,我已经接近我喜欢的方式,但是我无法弄清楚如何获取徽标(实际上只是 h1 文本)和标语,以与我的导航对齐。

徽标和标语的 html 是:

<div class="logo grid_5 omega">
    <ul>
      <li><a href="default.html"><h1>karma.</h1></a></li>
      <li><p id="tagline">A stop motion animation</p></li>
    </ul>
 </div>

到目前为止,它对应的 CSS 是这样的:

/* Header (Logo) -------------------------------------------------- */

.header.grid_12.omega {
    margin-top:40px;
    box-shadow:0 3px 10px #222;
    background:#FFFFFF;
}

.logo.grid_5.omega {
    float:left;
}

导航的html是:

<nav class="grid_7 omega">
            <ul>
              <li><a href="about.html">About</a></li>
              <li><a href="design.html">Process</a>
                  <ul>
                    <li><a href="#">Models</a></li>
                    <li><a href="#">Backgrounds</a></li>
                    <li><a href="#">Animation</a></li>
                    <li><a href="#">Post-production</a></li>                
                  </ul>
              </li>
              <li><a href="style.html">Style</a></li>
              <li><a href="reflection.html">Reflection</a></li>            
           </ul>
        </div>

  </nav>

它的CSS是:

/* 下拉导航 ---------------------------------------- */

nav ul ul {
    display:none;
}

    nav ul li:hover > ul {
        display: block;
    }

nav ul {
    background: #FFF; 
    padding: 0 20px;
    list-style: none;
    position: relative;
    display: inline-table;
}
    nav ul:after {
        content: ""; clear: both; display: block;
    }

nav ul li {
    float: left;
}
    nav ul li:hover {
        background: #4b545f;
    }
        nav ul li:hover a {
            color: #fff;
        }

    nav ul li a {
        display: block; padding: 25px 40px;
        color: #757575; text-decoration: none;
    }

nav ul ul {
    background: #5f6975; border-radius: 0px; padding: 0;
    position: absolute; top: 100%;
}
    nav ul ul li {
        float: none; 
        border-top: 1px solid #6b727c;
        border-bottom: 1px solid #575f6a;
        position: relative;
    }
        nav ul ul li a {
            padding: 15px 40px;
            color: #fff;
        }   
            nav ul ul li a:hover {
                background: #4b545f;
            }

但是,如您所见:它有点偏离:

http://imgur.com/HDofl9a

4

2 回答 2

1

我想你正在寻找这个

html

<div class="logo grid_5 omega">
    <ul>
      <li><h1><a href="default.html">karma.</a></h1></li>
      <li><p id="tagline">A stop motion animation</p></li>
    </ul>
 </div>

<nav class="grid_7 omega navigation">
            <ul>
              <li><a href="about.html">About</a></li>
              <li><a href="design.html">Process</a>
                  <ul>
                    <li><a href="#">Models</a></li>
                    <li><a href="#">Backgrounds</a></li>
                    <li><a href="#">Animation</a></li>
                    <li><a href="#">Post-production</a></li>                
                  </ul>
              </li>
              <li><a href="style.html">Style</a></li>
              <li><a href="reflection.html">Reflection</a></li>            
           </ul>
        </div>

  </nav>

css

.header.grid_12.omega {
    margin-top:40px;
    box-shadow:0 3px 10px #222;
    background:#FFFFFF;
}

.logo.grid_5.omega {
    float:left;
}
.logo.grid_5.omega li{
    float: left;
    line-height: 40px;
    list-style-type: none;
    margin-right: 25px;
    padding-top: 14px;
}

.navigation{
    float:left;
}
nav ul ul {
    display:none;
}

    nav ul li:hover > ul {
        display: block;
    }

nav ul {
    background: #FFF; 
    padding: 0 20px;
    list-style: none;
    position: relative;
    display: inline-table;
}
    nav ul:after {
        content: ""; clear: both; display: block;
    }

nav ul li {
    float: left;
}
    nav ul li:hover {
        background: #4b545f;
    }
        nav ul li:hover a {
            color: #fff;
        }

    nav ul li a {
        display: block; padding: 25px 40px;
        color: #757575; text-decoration: none;
    }

jsFiddle 文件

于 2013-06-14T06:19:08.323 回答
1

给你的主要 ul 一个 id 并给一些上边距?

HTML

<nav class="grid_7 omega">
    <ul id="navi">
        <li><a href="about.html">About</a></li>
        ...
    </ul>
</nav>

CSS

ul#navi{
    margin:30px 0 0 0; /*adjust your top margin*/
}
于 2013-06-14T05:32:28.957 回答