通过 1 个特定的单个子菜单定位父菜单

发布于 2025-01-09 21:57:24 字数 840 浏览 5 评论 0原文

我试图仅通过 1 个子菜单项来定位我的父菜单项。问题是,我只知道如何在类中定位类,而不是向后。我只想通过其中一个子菜单而不是全部子菜单来定位该父级。

原因: 我有一个子菜单项在多个父菜单中可见。当此子页面“lid worden”处于活动状态时,所有父页面都会变得活动。所以你永远不会知道你作为访客在哪个主菜单中。对于这个单页,我想关闭父级的活动样式。我已经为这个单个子菜单项指定了不同的类(.menu-lidworden)。所以CSS必须是这样的

.sub-menu.menu-lidworden.current_page_item --> .current-menu-parent
{ font-weight:normal 等...一些其他样式;}

我制作了 2 个打印屏幕,因为该网站仍在建设中并且处于离线状态。
https://dekeienatletiek.nl/hanneke/main-menu.png
https://dekeienatletiek.nl/hanneke/main-menu-html.png

如您所见,菜单“lid worden”位于父级“nieuws & uitslagen”中,但也在“over the keien”中。未来几乎所有的父母都会有这样的想法。正如我之前所解释的,所有这些都将因此而活跃。我不想要这样。

希望有人能帮助我解决这个问题。先感谢您

I'm trying to target my parent menu item through only 1 of my submenu items. The thing is, I only know how to target classes IN classes, not backwards. And I only want to target this parent through 1 of the submenus, not all of them.

The reason:
I have a sub menu item that is visible in more than one parent menu. When this sub page is active "lid worden", all the parents become active. So you will never know in what main menu you are as a visitor. For this single page, I want to turn off the active style of the parent. I already gave this single sub menu item a different class (.menu-lidworden). So the css must be something like this

.sub-menu.menu-lidworden.current_page_item --> .current-menu-parent
{ font-weight:normal etc... some other styles;}

I made 2 printscreens since the website is still under construction and offline.
https://dekeienatletiek.nl/hanneke/main-menu.png
https://dekeienatletiek.nl/hanneke/main-menu-html.png

As you can see, the menu "lid worden" is in the parent "nieuws & uitslagen" but also in "over the keien". In the future it will be in almost all the parents. As I explained before, all of them will be active because of this. And I dont want that.

Hope somebody can help me with this. Thank you in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹂绝世的画 2025-01-16 21:57:24

您可以尝试一些javascript,通过在触发单击事件(或其他事件,具体取决于您的需要)时调用一个函数,该函数检查所有父元素并从中删除任何活动的CSS类,然后将CSS类分配给仅限家长。

You can try some javascript , by calling a function when triggering the click event (or other events depending on what you need ) , this function check all the parents elements and remove any active CSS classes from them , and then assign the CSS classes to the parent only .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文