Jump to content

Archived

This topic is now archived and is closed to further replies.

balfred1345

How to highlight current menu item in NavBar

Recommended Posts

balfred1345

I'm trying to have current page highlighted in the menu item in NavBar.

 

I have tried a number of CSS options, but can't get any to work. 

 

Can you please tell me what I need to do to have my menu item highlighted when I'm on that corresponding page?

 

I'm developing the site here:

http://whub34.webhostinghub.com/~videoh6/cidev2.com/

 

Here are a few of my latest attempts:

 
/* Navbar Active Page Menu Item Background Color */
 
#page li.current-menu-item {
  box-shadow: 0 -4px 0 #8A0917 inset;
}
 
#page .navbar .navline > li.page_item .page-item-10 .current_page_item {
box-shadow: 0 -4px 0 #8A0917 inset !important;
}
  
#page .navbar.pl-color-base .navline > li.current-page-item {
  box-shadow: 0 -4px 0 #8A0917 inset !important;
}
 
#page .navbar.pl-color-base .navline > li.current-menu-item {
  box-shadow: 0 -4px 0 #8A0917 inset !important;
}

 

 

Thanks,

Bruce

 

Share this post


Link to post
Share on other sites
Rob

I think the CSS you need to modify is closer to

.navbar.pl-color-base .navline > li:hover > a, .navbar.pl-color-base .navline > li.current-menu-item > a, .navbar.pl-color-base .navline > li.dropdown.open > a {
    background-color: rgba(0, 0, 0, 0.66);
    box-shadow: 0 -4px 0 #8A0917 inset;
}
 
Complex CSS isn't my forte' so I'm going to suggest waiting for one of my colleagues or one of your fellow customers to answer, such as batman, who's amazing with this stuff.

Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
batman

Rob "who's amazing with this stuff"

:D 

 

Hi Bruce

Please, you can try with

 

 

a:active {

    box-shadow: 0px -4px 0px rgb(138, 9, 23) inset !important;

}

 

I´m not sure 


Life is too short to remove USB safely ...

Share this post


Link to post
Share on other sites
Danny

Hi,

 

Well you haven't set a custom menu to your NavBar, so its still using pages which are added by Wordpress.

So to target the current page in your menu you would need to use this:

 

#site .navbar .navline >li.current_page_item a {
background: #333;
color: #F00;
}
 
However, by default the NavBar should automatically have some styling in place.
 
When you create a Custom menu, this CSS will no longer work as the class changes from current_page_item to current_menu_item.
 
You can find more info by these Wordpress classes here - http://codex.wordpress.org/Function_Reference/wp_nav_menu#Menu_Item_CSS_Classes

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
balfred1345

Thanks for the replies Rob"] & @[member="batman.

 

Big thanks Danny -- You nailed it. I didn't realize I hadn't set the custom menu in NavBar. Once I set the custom menu, this CSS worked:

 

#page .navbar.pl-color-base .navline > li.current-menu-item {
  box-shadow: 0 -4px 0 #8A0917 inset !important;
}
 
Thanks also for the link to WordPress classes Codex page. I'd been using that, but beating my head against the wall, when the various things didn't work -- since I hadn't set the custom menu yet. 
 
Rob -- I used your CSS to style the open dropdown menu item. It worked nicely! Thanks very much!
 
I really appreciate the help!
 
-Bruce

Share this post


Link to post
Share on other sites
Danny

No problem, happy to help!


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Rob

You're very welcome Bruce.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites

  • Similar Content

    • Liv Kundalini
      By Liv Kundalini+
      Hi -
      Pulling my hair out over here, and would love an assist!
      Site I am building, http://www.livkundalini.com/home, has a problem with the submenu items in the nav not appearing. 
      If anyone wants to see what the Nav should look like, feel free to look in the footer on the left hand side.
      Have tried disabling Pagelines and using the twentyseventeen theme, but problem persists.
      Saw this error (pasted at the bottom of this post) displaying in the inspector, and saw discussion of Jetpack potentially being a culprit. Disabled Jetpack, but the problem persists.
      Had the hosting company even flush the server-side cache, but no avail.
      Any thoughts? Please? It's the only thing keeping me from launching this site!
      Many Thanks,
      Todd
       
      WebSocket connection to 'wss://public-api.wordpress.com/pinghub/wpcom/me/newest-note-data' failed: Error during WebSocket handshake: Unexpected response code: 403   O @ (index):7
    • russe-intensif
      By russe-intensif+
      Hi team,
      checking my site today, i'm surprised to see my MegaNav all in bottom of the pages, while it's in header.
      After getting to change it in couple of pages onto Template part (too time consuming !), i'm desperate and ask you for help :-)
      apprendre-le-russe-avec-ania.fr
      Thank you in advance !

    • Borries
      By Borries+
      I know this is not an easy problem. Maybe there is a easy solution.
      I have tryed to uses the existing solution, that I have found in the forum
      I changed the colours of my nav (simple nav) and the hover effect (a. hover).
      I really tryed to highlight the active/used link in the nav but I cant figure it out.
      I want it to be black when active.
      Any help would be appreciated. Thanks.
      http://www.marcborries.de  nav link: "Sinn & Selbst" 
    • dwpoyner
      By dwpoyner+
      Not sure exactly what is causing the issue. For some reason, why you view my site on mobile, the menu does not show up. It will pop up, but it is black. You can check it out here: http://dev.caryfbc.org. I'm also attaching a screenshot where I shrunk my browser down. Any suggestions?

    • khat
      By khat+
      I think I may have installed pagelines pro incorrectly, and then used features incorrectly. I installed first platforms framework theme and then the child, thinking I could do setup for child later. I tried to set up a background image, and tried custom css feature in pagelines dashboard. I had mistakes in my css, and just thought that if I deleted the info in the css custom feature in pagelines dashboard that the new information would overwrite the old info. The background image didn't respond at all, probably because I didn't have the child directory renamed. I then tried to use the LSS plugin to create css and added more css, possibly, somewhere -sigh-. I never did change the background image and get it placed properly. I used a workaround and in nested containers I placed a background image which worked well enough, so I moved on to try to create my nav bar/ menu bar. When I go to the Menus panel, there is NO area where I can place a menu on a page. I have read and reread and re- re- reread the instructions for placing a menu. I've used the pagelines editor to place a menu, however only HOME shows up. I've been at this for many hours. I've since uninstalled all of my pagelines items and reinstalled, thinking that it would restore all my changes to default, but no, it is still all there, with all my unresolved issues. I am completely at a loss as to what to do next.
×