简体   繁体   English

Hover 效果在子菜单中不起作用

[英]Hover effect isn't working in the sub-sub menu

I would like to create a dropdown menu that displays an image in the second dropdown.我想创建一个下拉菜单,在第二个下拉菜单中显示图像。 I have written the CSS code as it should be written, and I think there is no problem with the structure of my HTML code as well.我已经编写了应该编写的 CSS 代码,并且我认为我的 HTML 代码的结构也没有问题。 So, after hovering on Afyon White list item, there should be displayed an image(position is not adjusted yet) but it does not.因此,将鼠标悬停在 Afyon 白名单项目上后,应该会显示一个图像(位置尚未调整)但它没有。 Any suggestions?有什么建议么?

 /* regardless */ li { list-style: none; text-transform: uppercase; } /* theme.scss */.MegaMenu__Inner { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: nowrap; flex-direction: column; margin: 0 auto; padding: 0 10px; } @media screen and (min-width: 1240px) {.MegaMenu__Inner { max-width: 1280px; margin-left: auto; margin-right: auto; } } /* sca-jqueryblabla.scss */.MegaMenu__Item { display: inline-block; position: relative; width: 5rem; transition: all 0.9s ease-in-out; }.MegaMenu__Item >.MegaMenu__Title { display: inline-block; }.MegaMenu__Item >.MegaMenu__Title:hover { transition: all 0.9s ease-in-out; }.MegaMenu__Title--dropdown { display: none; position: absolute; z-index: 1; width: 100%; margin-top: -1.5rem; margin-left: 4rem; width: 100%; transition: all 0.9s ease-in-out; }.DropdownList--li { width: 9rem; padding: 0.4rem; }.MegaMenu__Title--dropdown.DropdownList { display: block; position: relative; }.MegaMenu__Item:hover.MegaMenu__Title--dropdown { display: block; transition: all 9s ease-in-out; }.MegaMenu__Item.MegaMenu__Item--fit { cursor: pointer; padding: 0.5rem; text-align: center; background-color: white; }.MegaMenu__Item.MegaMenu__Item--fit a { text-decoration: none; color: #5c5c5c; }.MegaMenu__Item { position: relative; }.Linklist { position: absolute; }.DropdownList { position: relative; display: inline-block; }.color-nav { display: none; position: absolute; width: 10rem; height: 10rem; border: 3px solid black; }.DropdownList--li:hover.color-nav { display: inline-block; }
 <div class="MegaMenu__Item MegaMenu__Item--fit"> <a href="" class="MegaMenu__Title Heading Text--subdued u-h7" >White</a> <div class="MegaMenu__Title--dropdown"> <ul class="DropdownList DropdownList_White"> <li class="DropdownList--li DropdownList_White--li"> <a>Afyon White</a> </li> <div class="color-nav"> <img src="" alt=""> </div> </ul> </div> </div>

The following <div> :以下<div>

 <div class="color-nav">
         <img src="" alt="">
 </div>

should be inside the <li> that has the class DropdownList--li DropdownList_White--li in order to be able to be selected as per your CSS which is:应该在具有 class DropdownList--li DropdownList_White--li<li>内,以便能够根据您的 CSS 进行选择,即:

.DropdownList--li:hover .color-nav {
  display: inline-block;
}

That is, above, you are selecting .color-nav as a child of .DropdownList--li , but in your HTML the .color-nav is not its child.也就是说,在上面,您选择.color-nav作为.DropdownList--li的子级,但在您的 HTML 中, .color-nav不是它的子级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM