Site logo

[Resolved] How to have the submenu navigation toggled down on open?

Home Forums Support [Resolved] How to have the submenu navigation toggled down on open?

Home Forums Support How to have the submenu navigation toggled down on open?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2554475
    Stefan

    hello everybody,
    I wonder if you can help me .
    I want to have the submenu on show by default when I click the menu button on mobile view. how can I implement that ?
    and can I use the css only for one navigation button and not for the whole navigation bar
    the website is https://inkaholics.co.uk

    Thank you in advance, Stefan

    #2554596
    Ying
    Staff
    Customer Support

    Hi Stefan,

    Can you try this CSS:

    
    .main-navigation.toggled .main-nav ul ul.sub-menu {
            position: relative;
            top: 0;
            left: auto!important;
            right: auto!important;
            width: 100%;
            pointer-events: auto;
            height: auto;
            opacity: 1;
            display: block;
            visibility: visible;
    }
    #2554655
    Stefan

    Hi thank yo u for the swift reply,
    yes it works but when I press the little arrow on the right the dropdown doesn’t retract .. also can’t scroll down to the contacts .
    wanted just the Artists one to be collapsed .
    i have left live to see how it behaves

    #2555182
    David
    Staff
    Customer Support

    Hi there,

    you won’t be able to do it with CSS.
    It would need some Javascript.

    1. Create a new Hook Element ( in Appearance > Elements ).
    2. In the hook text area add this script:

    
    <script>
    const clickme = document.querySelector('#menu-item-584 .dropdown-menu-toggle')
    const elemHtml = document.querySelector('html')
    const mutateOptions = {
      attributes: true
    }
    
    function callback(mutationList, observer) {
      mutationList.forEach(function(mutation) {
        if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
          // handle class change
          if (mutation.target.className == 'mobile-menu-open') {
            clickme.click();
          }
        }
      })
    }
    
    const observer = new MutationObserver(callback)
    observer.observe(elemHtml, mutateOptions)
    </script>

    3. Set the Hook to: wp_footer
    4. Set the Display Rules > Location to Entire Site
    5. Publish the hook.

    #2556063
    Stefan

    Hi David ,
    It worked amazing , no problem whatsoever .thank you again for your support.
    Regards,Stefan

    #2556280
    David
    Staff
    Customer Support

    Glad to hear that!

    #2556706
    Stefan

    Very happy with the technical support, and the generate press theme . Thank you

    #2557102
    David
    Staff
    Customer Support

    Glad to be of help!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.