-1

I have a menu in WordPress site with 4 items - Home - Portfolio - Team - Connect

I want to highlight menu item of current page being visited but each page should have different color. For example if I visit home page the Home menu item should be green.

enter image description here

If I visit portfolio page then portfolio menu item should be green.

enter image description here

Jawaid
  • 99
  • 1
  • 4
  • 17

2 Answers2

0

you can use like this

ul li.active:first-child {
  color:blue;
}

ul li.active:nth-child(2) {
    color: red;
}


ul li.active:nth-child(3) {
    color: green;
}
Vel
  • 9,027
  • 6
  • 34
  • 66
0

I found a solution. Since theme is based on Twitter Bootstrap an .active class is added to the current page's menu item being visited. Therefore, I added a separate class like .home for home page, .portfolio to portfolio page, and then chain the classes to take effect like this.

.navbar-nav > .home.active > a {
    color: green !important;
}

Notice the .home.active classes are chained.

Following threads on SO were helpful.

css select an element with 2 class

CSS Selector that applies to elements with two classes

Jawaid
  • 99
  • 1
  • 4
  • 17