Computer User
Computer User

Reputation: 2879

Change hover blue color of top menu using CSS / jQuery

I am trying to change the blue hover color of top menu to black on my website using CSS / jQuery:

Image of a horizontal menu

I have written following code:

<style>
#menu-top:hover { color: #000 }
.nav-menu:hover { color: #000 }
</style>

But it does not change the color.

Upvotes: 0

Views: 241

Answers (1)

Scrapper142
Scrapper142

Reputation: 586

Two problems

  1. you are using color which changes text color instead of background-color
  2. you are trying to change the entire navbar when hovered, instead of the elements. Use a combinator to match the elements you want, for example, .nav-menu *:hover matches any element that is a descendent of the navbar (this seems to work on this site)

So the final might look like

<style>
#menu-top *:hover { background-color: #000 }
.nav-menu *:hover { background-color: #000 }
</style>

Upvotes: 1

Related Questions