Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1310865

    I have a Menu with a header of 240px so I can show an image behind the menu.
    And it is set to Shrinking Menu otherwise the header covers too much on the browser page

    Currently on a fresh screen the menu sits in the middle of the header area
    And when it shrinks, it moves to the bottom of the Header.

    How can I make the menu sit at the bottom of the header ALL the time?

    2 images

    Normal Header
    https://pasteboard.co/Kc1uGS7.jpg

    Shrinking Header
    https://pasteboard.co/Kc1uXQb.jpg

    #1311030

    Hey wealthyone,

    Thanks for the screenshots. Could you post a link to where we can see the actual elements on your site as well please?

    Best regards,
    Rikard

    #1311164

    Link posted below

    #1312127

    Hi,
    Thank you for your patience and the link to your site, this is a tricky request as the shrinking header is calculated by javascript, the following javascript seems to work but it is not as smooth as I would expect.
    Try adding this code to the end of your functions.php file in Appearance > Editor:

    function custom_script() { ?>
        <script>
    const parent = document.getElementsByClassName("av-logo-container")[0];
    const child = document.getElementsByClassName("av-main-nav")[0];
    document.addEventListener("scroll", checkParent);
    let lastHeight = 0;
    
    function checkParent() {
      const parentHeight = parent.clientHeight;
    
      if (parentHeight >= 240) child.style.paddingTop = "110px";
      else child.style.paddingTop = "0px";
    }
    
    function checkForChanges() {
      const parentHeight = parent.clientHeight;
      if (parentHeight != lastHeight) {
        checkParent();
        lastHeight = parentHeight;
      }
      setTimeout(checkForChanges, 100);
    }
    
    checkForChanges();
    </script>
        <?php
    }
    add_action('wp_footer', 'custom_script');

    Best regards,
    Mike

    #1312150

    Hey great thanks.
    This will do for a start.
    Appreciate your coding expertise

    #1312254

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Menu position on Header’ is closed to new replies.