1. bibbp
  2. Sherlock Holmes
  3. Commercial Templates
  4. Tuesday, 15 January 2019
  5.  Subscribe via email
Hi Ciaran,

I have a client who wants an image (a roof) to appear over each top line menu items, but not over sub-menu items. They want the roof to stay in place if that menu item is active.
I have a process that works but it requires manual creation of CSS for every new menu item, supposing the menu item is .item-136 and the sub menu item is .item-137, then I have the following CSS:

.item-136.active {
background-image: url("https://independentliving.scottsproject.org.uk/images/web/Roof.png";);
background-repeat: no-repeat;
background-position: 50% 0%;
}
.item-136 a:hover {
background-image: url("https://independentliving.scottsproject.org.uk/images/web/Roof.png";);
background-repeat: no-repeat;
background-position: 50% 0%;
}
.item-137 a:hover {
background-image: none;
}

I am sure if I put a class ("roof";) on the Link Class of just the top menu item, then I can't understand why the following does not work: the hover piece works but not the active.

.roof.active {
background-image: url("https://independentliving.scottsproject.org.uk/images/web/Roof.png";);
background-repeat: no-repeat;
background-position: 50% 0%;
}
.roof:hover {
background-image: url("https://independentliving.scottsproject.org.uk/images/web/Roof.png";);
background-repeat: no-repeat;
background-position: 50% 0%;
}

Any help would be greatly appreciated

Kind regards

Peter
Accepted Answer Pending Moderation
0
Votes
Undo
Hi Peter

To select only the active parent menu items and the hover of the parent items, you can use the following CSS selector...

.hornav > ul > li.active a,
.hornav > ul > li a:hover, {
...
}


Ciaran
  1. more than a month ago
  2. Commercial Templates
  3. # 1
Accepted Answer Pending Moderation
0
Votes
Undo
Ciaran,

For your readers I also added:

.hornav > ul > li > ul > li.active a,
.hornav > ul > li > ul > li a:hover {
background-image: none;
}

to remove the image from the submenu items.

Thank you very much!

Peter
  1. more than a month ago
  2. Commercial Templates
  3. # 2
Accepted Answer Pending Moderation
0
Votes
Undo
Apologies Ciaran, minor glitch..

If you go to https://www.scottsproject.org.uk/ and select submenu item About Us under the top menu item About Us, then if you place the cursor back over the top level menu item (About Us) then the images appear in the submenu items underneath...these should all be invisible.

Again, any help would be much appreciated!

Peter
  1. more than a month ago
  2. Commercial Templates
  3. # 3
Accepted Answer Pending Moderation
0
Votes
Undo
Hi Peter

To amend replace the following...

.hornav > ul > li.active a, .hornav > ul > li a:hover {
background-image: url("https://dayservices.scottsproject.org.uk/images/web/Roof.png");
background-repeat: no-repeat;
background-position: 50% 0%;
}


With...

.hornav > ul > li.active > a, .hornav > ul > li a:hover {
background-image: url("https://dayservices.scottsproject.org.uk/images/web/Roof.png");
background-repeat: no-repeat;
background-position: 50% 0%;
}


Ciaran
  1. more than a month ago
  2. Commercial Templates
  3. # 4
Accepted Answer Pending Moderation
0
Votes
Undo
Perfect, thanks as always

Peter
  1. more than a month ago
  2. Commercial Templates
  3. # 5
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!

Join Our Newsletter

* indicates required
We respect your privacy and do not tolerate spam and will never sell, rent, lease or give away your information (name, email, number, etc.) to any third party. Nor will we send you unsolicited email.
Joomla51 - Mullaghmore, Co. Sligo, Ireland
Joomla51.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by
Open Source Matters
the trademark holder in the United States and other countries.