【问题标题】:Drop Down menu in wordpress themewordpress 主题中的下拉菜单
【发布时间】:2013-03-11 19:07:02
【问题描述】:

我正在使用一个免费的 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

【问题讨论】:

  • 如果你使用 ul#mainmenu-menu > li.menu-item:first-child 它只会影响直接的孩子
  • 我该如何解决?

标签: css drop-down-menu


【解决方案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

【讨论】:

  • @ShuvroShuvro 不客气,您现在可以将此问题标记为已回答!
猜你喜欢
  • 2017-07-18
  • 2013-10-30
  • 1970-01-01
  • 2016-06-23
  • 1970-01-01
  • 2023-03-04
  • 2012-05-17
  • 2014-05-04
  • 1970-01-01
相关资源
最近更新 更多