在wordpress主题下拉菜单

时间:2013-03-11 19:07:03

标签: css drop-down-menu

我正在使用免费的WordPress主题,名为Pitch siteorigin.com/theme/pitch。我重新设计菜单栏,以便菜单栏的第一个元素的背景将显示图像(徽标)。为此,我只添加一个简单的代码块

ul#mainmenu-menu li.menu-item:first-child {
        background:url(images/logo.png) no-repeat ;
        text-indent:-9999px;
        width:200px;


        border:none;
        }
    ul#mainmenu-menu li.menu-item:first-child a:hover  {
        background:none;

    }

但问题是,该图像也出现在下拉项的第一个元素中。像图像一样 http://i46.tinypic.com/oejcz.jpg

我做错了什么,我该如何解决这个问题?

以下是完整的CSS代码http://pastebin.com/edsYrqWF

1 个答案:

答案 0 :(得分:1)

像这样更改你的CSS:

ul#mainmenu-menu > li.menu-item:first-child {
    background:url(images/logo.png) no-repeat ;
    text-indent:-9999px;
    width:200px;
    border:none;
}
ul#mainmenu-menu > li.menu-item:first-child a:hover  {
    background:none;
}

它仅适用于您的第一个菜单级别,而不适用于子菜单。请注意">"在CSS。

此处有更多信息:http://www.w3.org/TR/CSS2/selector.html#pattern-matching

相关问题