Where to apply: hover over to save the css submenu in a frozen state

I am trying to create a drop down menu. Some people have helped me Disable CSS menus only .

Everything works fine, except that I hover over my submenu. The background image of the guidance state in mine #menubar #test2 a:hoverwill return to the state #menubar #test2 a. I really need to do this, and I will be grateful if anyone can help me. Thanks a million.

My html

<ul id="menuBar">
   <li id="test1">test1</li>
   <li id="test2"><a href="#">Pro1</a>
     <div class="subMenu">
        <ul>
           <li><a href="#">sub1</a></li>  
           <li><a href="#">sub2</a></li>
           <li><a href="#">sub3</a></li>
         </ul>
         <ul>
            <li><a href="#">Volleyball</a></li>
            <li><a href="#">Walking</a></li>
            <li><a href="#">Water Shoes</a></li>
         </ul>
       </div> <!--end of submenu-->
     </li>
  </ul>

CSS

#menuBar #test2 a{
background:url("../images/btTest.jpg") no-repeat bottom;
display:block;
border-right:1px solid #ffffff;
width:112px;
height:37px;
}

#menuBar #test2 a:hover{
background:url("../images/btTest.jpg") no-repeat top;
}  

#menuBar #test2 a:hover + .subMenu { //submenu show up
display:block;

} 

#menuBar li .subMenu:hover {  //keep submenu show up when hover in submenu
display: block; 
}

//the next one is not working....but I can't think of anything....
#menuBar li .subMenu:hover #menuBar #mens a {  
background:url("../images/btMen.jpg") no-repeat top;
}
0
source share
1 answer

You need the following:

#menuBar #test2 a:hover{
   background:url("../images/btTest.jpg") no-repeat top;
} 

For this:

#menuBar #test2:hover a {
  background:url("../images/btTest.jpg") no-repeat top;
}

, .subMenu. IE6 ( ).

:

#menuBar #test2 a:hover + .subMenu { //submenu show up
  display:block;
} 

#menuBar li .subMenu:hover {  //keep submenu show up when hover in submenu
  display: block; 
}

:

#menuBar li:hover .subMenu {
  display: block;
}
+4

Source: https://habr.com/ru/post/1756090/


All Articles