Wordpress - 选择/加载子菜单项页面时突出显示父菜单项 [英] Wordpress - Highlight the parent menu-item when child menu item page is selected/loaded

查看:39
本文介绍了Wordpress - 选择/加载子菜单项页面时突出显示父菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本菜单,有些菜单项有子菜单.我对 wordpress 的经验很少,现在没有时间深入研究细节.所以我的问题是,当用户导航到子菜单页面之一时,突出显示顶部菜单项的最简单方法是什么.(我尝试使用 javascript 和纯 css 通过元素 id 和使用current-cat-parent"类来设置颜色属性,但都没有奏效.
非常感谢任何帮助.

I have a basic menu and some of the menu items have submenus. I have very little experience with wordpress and don't have time to dive deeper into the details right now. So my question is, what is the simplest way to highlight the top menu item when the use navigates to one of the submenu pages. (I tried using both javascript and also pure css to set the color property by element id and by using the "current-cat-parent" class but neither worked).
Any help is greatly appreciated.

注意:我使用了一个叫做变色龙的主题.

Note: I am using a theme called chameleon.

推荐答案

您可以将 current-menu-item 类分配给 .current-menu-ancestor 类,例如

you can assign current-menu-item class to .current-menu-ancestor class like

.main_menu li.current-menu-item a, .main_menu li.current-menu-ancestor a{
    color: #777777 !important; /* highlight color */
}

它将突出显示父页面菜单

It will highlight parent page menu

请参考 本页

这篇关于Wordpress - 选择/加载子菜单项页面时突出显示父菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆