导航中心

时间:2013-07-17 16:02:05

标签: css html5

我似乎无法弄清楚如何允许绝对居中的徽标被我的导航链接(每侧3个)包围,并且在调整大小时导航将落在徽标下方:{{3} }。如果在其他地方得到解答,我会提前道歉。任何帮助将不胜感激!

以下是代码:

LOGO CSS

h1.logo {
    float: none;
    left: 50%;
    margin-left: -80px;
    text-align: center;
}

h1.logo a {
    background: url("images/logo.png") no-repeat scroll 0 0 transparent;
    display: block;
    float: none;
    height: 127px;
    text-align: center;
    text-indent: -9999px;
    width: 181px;
}

.abs {
    position: absolute;
}

NAVIGATION CSS

.nav {
    position: relative;
}
#navigation ul li, #navigation ul li a {
    border: medium none !important;
    color: #3C3F40;
    display: block;
    float: right;
    font-family: 'Fjord One',"Times New Roman",Times,serif;
    font-weight: normal;
    margin: 42px 0 130px !important;
    padding: 15px 25px;
    position: relative;
    text-align: center !important;
    text-decoration: none;
    text-transform: uppercase;
}
#navigation ul li:hover a, #navigation ul li a:hover {
    color: #D9A13B;
}
#navigation ul li:hover li a {
    color: #D9A13B;
    font-weight: normal;
}
#navigation ul li.active a {
    color: #D9A13B;
}
#navigation ul.sub-menu {

}
#navigation ul.sub-menu li {
    border: medium none;
}
#navigation ul.sub-menu li a {
    background: none repeat scroll 0 0 transparent;
    border-bottom: medium none;
    border-radius: 0 0 0 0;
    height: 32px;
    line-height: 32px;
    min-width: 210px;
    padding: 5px 0 5px 8px;
    position: static;
}
#navigation ul.sub-menu li a:hover {
    border-bottom: medium none;
}

HTML:

<header class="sixteen columns">



 <nav>

    <h1 class="logo abs">
    <a href="/">Bound By Design</a>
    </h1>

    <div id="navigation" class="row sixteen columns">
        <div class="menu-header">

            <ul id="menu-primary-menu" class="menu sf-js-enabled">

                <li id="menu-item-40" class="menu-item menu-item-type-post_type menu-item-
               object-page current-menu-item page_item page-item-4 current_page_item menu-item-40 active">
                <a href="http://testsite.brentthelendesign.com/">Home</a>
                </li>
                <li id="menu-item-41" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-41">
                <a href="http://testsite.brentthelendesign.com/category/tattoos/">Tattoos</a>
                </li>
                <li id="menu-item-42" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-42">
                <a href="http://testsite.brentthelendesign.com/category/piercings/">Piercings</a>
                </li>
                <li id="menu-item-60" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-60">
                <a href="http://testsite.brentthelendesign.com/aftercare/">Aftercare</a>
                </li>
                <li id="menu-item-58" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-58">
                 <a href="http://testsite.brentthelendesign.com/category/news/">News</a>
                </li>
                <li id="menu-item-59" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59">
                <a href="http://testsite.brentthelendesign.com/contact/">Contact</a>
                </li>
           </ul>
        </div>
     </div>
   </nav>
</header>

2 个答案:

答案 0 :(得分:2)

只需添加:

#navigation ul li:nth-child(3) {
  margin-right: 213px!important;
}

到layout.css,它将处理徽标问题。

此外:

#navigation ul li, #navigation ul li a { 15px 0 26px 0 !important; }

将摆脱导航和'欢迎'之间的差距

答案 1 :(得分:0)

这种方法对徽标和页面宽度的依赖程度较低:

#menu-primary-menu {width: 100%}
#menu-primary-menu > li:nth-child(n+4) {float: right}

请注意,您必须颠倒3个右浮动菜单项的顺序,因为它们是从右向左堆叠的。