-
AuthorPosts
-
January 20, 2017 at 12:36 pm #736381
Hi there,
how can I apply a active menu item color and a hover color to the active menu item?
Thanks
- This topic was modified 7 years, 10 months ago by clairemartindigital.
January 24, 2017 at 9:00 am #737600Hey clairemartindigital!
Thank you for using Enfold.
Please add this in the functions.php file.
// menu active function add_custom_script(){ ?> <script> (function($){ // cache selectors function ab() { var lastId, topMenu = $(".av-subnav-menu"), topMenuHeight = topMenu.outerHeight(), // all list items menuItems = topMenu.find("a"), // anchors corresponding to menu items scrollItems = menuItems.map(function(n, i){ var item = $(i).attr("href"); if (item.length && item.indexOf("#") != -1) { return item; } }); $(window).scroll(function(){ // get container scroll position var fromTop = $(this).scrollTop()+topMenuHeight, fromTop = fromTop + 150; // get anchors var anchors = scrollItems.map(function(n, i){ var item = i.substring(i.indexOf("#")); return item; }); var section = $('.avia-section').each(function() { return this; }); section = section.map(function() { if ($(this).offset().top < fromTop) return this; }); // get the id of the current element var cur = section[section.length-1]; var id = section && section.length ? section[section.length-1].id : ""; current = $(cur).attr('id'); if (lastId !== id) { lastId = current; menuItems.parent().removeClass("active").end().filter("[href*='#"+current+"']").parent().addClass("active"); } }); } ab(); function a() { $('#top .av-submenu-container').append("<a href='http://thymeforachef.com.au/#top' class='submenu_logo'><img src='//thymeforachef.com.au/wp-content/uploads/2017/01/Megara-logo-340x156.png' /></a>"); } a(); })(jQuery); </script> <?php } add_action('wp_footer', 'add_custom_script');
And this code in the Quick CSS field.
#top .av-subnav-menu > .active > a { color: red; }
Best regards,
IsmaelJanuary 24, 2017 at 10:01 am #737632Hi Ismael,
thanks for getting back. It seems that your solution is currently not working for me. Can you have another look please?
Thanks
January 30, 2017 at 9:51 am #740092Hi,
We modified the code a bit. Please remove browser cache before checking the page.
Best regards,
IsmaelJanuary 30, 2017 at 11:22 am #740133Hi Ismael,
thanks so much for the response. In terms of the request, we are getting there. A couple of issues still.
1. The pages ‘Resources’ and ‘Privacy’ have the sub nav as well. The code is not getting applied to those pages. In other words, no active menu color is getting displayed. This also applies to the News blog as well as the posts in the news blog. Can you have another look please?
2. Also, how can I add a mouse over color to the menus items?
Thanks so much!
January 31, 2017 at 7:02 am #740501Hey!
1.) Please add this css code.
.current-menu-item a { color: red; }
Unfortunately, this is not going to work if you’re on a single post page.
2.) And add this css code.
#top .av-subnav-menu li a:hover { color: red; } #top .widget_nav_menu a:hover { color: blue; }
Regards,
IsmaelJanuary 31, 2017 at 7:59 am #740519Hi Ismael,
thank you for getting back. Almost there.
1. I understand that it won’t work on a single post page as you mentioned. That is no problem. However, I still can’t get the ‘News’ & ‘Resources’ pages to display the active menu item color. Do you have an idea why this is the case?
2. Thanks, in principle this is what i was after. However, the active menu item is now also taking on the hover color. Where as it should remain the active menu item color. Any ideas?
Thank you!
February 1, 2017 at 6:16 am #740999Hi!
1.) Please adjust the code a bit.
#top .av-subnav-menu > .current-menu-item > a { color: red !important; }
2.) I’m not sure what you mean by that. I checked the site and hover color is black while the active menu is blue.
Cheers!
IsmaelFebruary 1, 2017 at 6:25 am #741002Hi Ismael,
1. thanks, now the ‘news’ and ‘resources’ menu item take on the active color. however, now the ‘home’ menu item is permanently in the hover color, even when not on the ‘home element’ (the slider at the top’.
2. disregard.
Do you have a solution for item 1?
Thanks Ismael
February 2, 2017 at 3:41 pm #741846Hey!
Please add following code to Quick CSS to remove home menu item from your homepage
.home #menu-item-588 { display: none!important; }
Regards,
YigitFebruary 3, 2017 at 1:55 am #742133Hi Yigit,
i guess that option would be the last possible resort.
What I was referring to is that the home menu item should only take on the hover color when the user is at the very top of the page ie on the layerslider hero. Does that make sense?
February 7, 2017 at 7:43 am #743703Hi Yigit,
maybe I need to make my question clearer.
Is there a way to apply a unique id to the layerslider at the top of the page and make that id a menu anchor?
Thanks
February 8, 2017 at 8:51 pm #744488Hi,
Yes that is possible using jQuery.
If LayerSlider found apply class to menu and manipulate the CSS.
Unfortunately it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However if its really important for you to get this done, you can always hire a freelancer to do the job for you :)
If you like to get started on your own please find similar examples here
http://stackoverflow.com/questions/13358887/should-i-use-hasclass-before-addclass
http://stackoverflow.com/questions/4208051/if-hasclass-then-addclass-to-parentAdd your jQuery code in this format to the bottom of functions.php file which can be accessed from Appearance > Editor
function custom_func(){ ?> <script> /* Your code here */ </script> <?php } add_action('wp_head', 'custom_func');
Best regards,
Vinay- This reply was modified 7 years, 9 months ago by Vinay.
February 8, 2017 at 11:19 pm #744546alright thanks – you can close this. could someone have a look at this post: https://kriesi.at/support/topic/border-around-masonry-title-underneath-thumbnail/
Thanks
February 10, 2017 at 3:59 am #745184Hi,
We will answer your other ticket, to know more about enfold features please check – http://kriesi.at/documentation/enfold/
Thank you for using Enfold :)
Best regards,
Vinay -
AuthorPosts
- The topic ‘full width sub menu styling’ is closed to new replies.