Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

make menu hover: body with dark shadow

  • Hello, i´m really in love with the GP theme, very, very great work!!

    Would you can help me make this effect or any ticket / documnetation allready exist?

    I need, when from PC the menu is hover, make a body “dark shadow” (like the picture example).

    https://imgur.com/a/wkKaoLN

    It is my first support topic, sorry my english, have a nice day 🙂

  • Hi there,

    It seems achievable using some CSS. The topic here appears to be similar to what you want to achieve:
    https://generatepress.com/forums/topic/navigation-overlay/

    I checked your site, but it doesn’t have the menu navigation, so I cannot do any testing.

  • Hello again, yes i have tried this topic, but there is not the correct result for me, when clicked, the shadow is on sub-menu item, not on body, and my menu is hover, not clicked. (please see image)

    https://imgur.com/a/6I2gsu1

    Sorry, the website was maintenance mode, just i turned on, now you can see it 🙂

  • Hi there,

    that method will only work when you have a fill width sub menu.
    So remove that CSS, as what you need will require some Javascript.

    1. Hook in the following script to the wp_footer

    
    <script>
    
    const body = document.querySelector('body');
    const menuItems = document.querySelectorAll('.menu-item-has-children');
    
    const observer = new MutationObserver(mutations => {
    
      mutations.forEach(mutation => {
    
        if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
    
          const target = mutation.target;
          const hasHoverClass = target.classList.contains('sfHover');
    
          if ( hasHoverClass ) {
            body.classList.add('submenu-open');
          } else {
            body.classList.remove('submenu-open');
          }
        }
      });
    });
    
    menuItems.forEach(item => observer.observe(item, { attributes: true }));
    </script>
    

    This observes the sfHover class when a sub menu is open and in turn adds a class of of submenu-open to the body tag.

    2. Add this CSS to style the page container when the submenu-open is present:

    
    .submenu-open #page {
        filter: brightness(0.5);
    }
    
  • Worked, thank you a lot, i am very happy, it is a great support!

  • Glad to be of help!

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