问题描述
我有一个嵌套的 CSS 菜单,我无法显示子菜单.
I have a nested CSS menu that I can't get the submenus to come up.
我从 一个列表分开获取代码.该站点上的示例运行良好,但由于我的页面上有 2 个 CSS 导航菜单,我必须将我的 HTML 元素放在不同的 CSS 类中.
I took the code from A list apart. The example on that site works perfectly fine, but since I have 2 CSS navigational menus on my page, I have to put my HTML elements in different CSS classes.
这是我的代码:
现在,当我将鼠标悬停在 1 级的a"上时,2 级的ul"不会出现.有人可以阐明一下吗?我可能遗漏了一些明显的东西.谢谢!
Now when I hover over the "a" on level 1, the "ul" on level 2 won't come up. Can someone please shed some light? I may be missing something obvious. Thanks!
推荐答案
你必须改变你的 CSS 选择器来定位 lvl2 <ul>
,因为它不再嵌套(它是一个兄弟,所以使用 +).
You must change your CSS selector to target the lvl2 <ul>
, since it is not nested anymore (it's a sibling, so use +).
你应该阅读这个css 选择器列表.
或者您可以将鼠标悬停在 lvl1 <li>
上,而不是锚点
Or you could move the hover on the lvl1 <li>
, instead of the anchor
这篇关于悬停一个元素,然后更改另一个元素(不使用 Javascript)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!