解决谢谢!
我需要将 css 应用到当前事件菜单(PARENT LIST li 元素),这是我的代码:
#supermenu li.current-menu-item a, #supermenu li.current-menu-item a:hover {
font-weight: bold;
color: #fff;
background-color: #ea6ea0;
border-right: 1px solid #ea6ea0;
box-shadow:inset 0 -1px 2px #bf1358;
}
覆盖子链接看起来是一个漫长而困惑的过程,有什么干净的方法可以排除子链接吗?
但是 css 被应用于子链接/ anchor ,因为它与下拉菜单一起使用,我怎样才能阻止子链接具有相同的 css?
谢谢
最佳答案
如果我理解正确,请试试这个:
#supermenu li.current-menu-item > a,
#supermenu li.current-menu-item > a:hover {
font-weight: bold;
color: #fff;
background-color: #ea6ea0;
border-right: 1px solid #ea6ea0;
box-shadow:inset 0 -1px 2px #bf1358;
}
你可以看看这个article理解 >
child combinator .
请注意,它不适用于 IE6 或更低版本。
关于css - 如何将 CSS 应用于仅具有事件类(仅限父级)而不包括子级的 anchor ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13439786/