-
AuthorPosts
-
July 20, 2021 at 11:15 am #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 pageCurrently 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.jpgShrinking Header
https://pasteboard.co/Kc1uXQb.jpgJuly 21, 2021 at 6:48 am #1311030Hey 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,
RikardJuly 21, 2021 at 3:38 pm #1311164Link posted below
July 24, 2021 at 11:42 pm #1312127Hi,
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,
MikeJuly 25, 2021 at 6:10 am #1312150Hey great thanks.
This will do for a start.
Appreciate your coding expertiseJuly 25, 2021 at 10:35 pm #1312254Hi,
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 -
AuthorPosts
- The topic ‘Menu position on Header’ is closed to new replies.