如何让我的徽标和标语与我的导航对齐?

时间:2013-06-14 05:22:11

标签: html css alignment

我一直致力于下拉导航,我已经接近我的喜好但是我无法弄清楚如何获得徽标(实际上只是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

2 个答案:

答案 0 :(得分: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*/
}

答案 1 :(得分: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 File