Css wordpress主题中的下拉菜单
我正在使用一个免费的wordpress主题,名为Pitch。我重新设计了菜单栏,以便菜单栏第一个元素的背景将显示一个图像(徽标)。为此,我只需添加一个简单的代码块Css wordpress主题中的下拉菜单,css,drop-down-menu,Css,Drop Down Menu,我正在使用一个免费的wordpress主题,名为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 {
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代码按如下方式更改您的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中的“>”
此处的更多信息:如果您使用ul#主菜单>li。菜单项:第一个孩子它只会影响直接儿童秀我能解决吗?@ShuvroShuvro不客气,您现在可以将此问题标记为已回答!