Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Accessing Dropdown menu

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ,

Below is my code :

May I know why hovering doesn't work on line no 39 at present and only works if I change it to .dropdown:hover .dropdown-content { ?
Since there are two classes overlapped on each other, can i not access the child class without going through the parent class ?
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In future posts, please be sure that your code is properly indented.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

raman kadam wrote:only works if I change it to .dropdown:hover .dropdown-content { ?


Change it from what? You've only given us half of the story.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a.dropbtn:hover .dropdown-content reads as "a.dropbtn:hover is an ancestor to .dropdown-content" - now take a look at your HTML.
Hint: Adjacent sibling selectors | MDN.

That being said probably best stick to the fix that you have already found.
How to Create a Simple CSS Dropdown Menu - Treehouse Blog
Simple Pure CSS Drop Down Menu | codepen
 
raman kadam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

I meant 'change it from a.dropbtn:hover .dropdown-content{ (line #39) to .dropdown:hover .dropdown-content {
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
.dropdown-context isn't a child of the <a> element, is it?
 
raman kadam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right Bear! It's a sibling , not a child.

Thank you so much Bear and Peer !
 
reply
    Bookmark Topic Watch Topic
  • New Topic