Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #736381

    Hi there,

    how can I apply a active menu item color and a hover color to the active menu item?

    Thanks

    #737600

    Hey 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,
    Ismael

    #737632

    Hi Ismael,

    thanks for getting back. It seems that your solution is currently not working for me. Can you have another look please?

    Thanks

    #740092

    Hi,

    We modified the code a bit. Please remove browser cache before checking the page.

    Best regards,
    Ismael

    #740133

    Hi 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!

    #740501

    Hey!

    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,
    Ismael

    #740519

    Hi 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!

    #740999

    Hi!

    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!
    Ismael

    #741002

    Hi 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

    #741846

    Hey!

    Please add following code to Quick CSS to remove home menu item from your homepage

    .home #menu-item-588 {
        display: none!important;
    }

    Regards,
    Yigit

    #742133

    Hi 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?

    #743703

    Hi 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

    #744488

    Hi,

    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-parent

    Add 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.
    #744546

    alright 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

    #745184

    Hi,

    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

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘full width sub menu styling’ is closed to new replies.