-
AuthorPosts
-
November 13, 2023 at 11:47 am #1425430
Hi Mike,
I found a new issue with the site as I started to populate the menu further.
The last item on the menu “About Us”. I am using Mega Menu to populate most of the menu items. All but this last one work good and are LEFT aligned automatically. They all start at the same point (the very left edge of the site) without any prompting from me. They are all varying column numbers: The “Information” nav item uses 5 columns, “Support and Education” I have set to use 3 columns but 2 rows, and “Get Involved” uses 4 columns.
However when it comes to the “About Us” nav item it is not aligning in the same manner. It starts right at the right edge of the menu item and then disappears off the right edge of the screen. I seem to remember previously that the right side mega menu items tended to be right aligned to the site and then extend leftwards… It seems something has stopped this…
Could you assist please?
Thanks as always,
James.November 15, 2023 at 5:45 am #1425649Hey jamesbarrell,
Thank you for the inquiry.
We may need to login to the site in order properly check the issue. Please provide the login details in the private field. Have you tried moving the “About Us” menu item to a different position in the menu?
Best regards,
IsmaelNovember 15, 2023 at 9:20 am #1425656This reply has been marked as private.November 17, 2023 at 12:51 pm #1425832This reply has been marked as private.November 18, 2023 at 3:44 pm #1425930Hi,
Thank you for your patience, it seems that the issue is the flex css we used to change the position of the menu items equally across the header, the position of the mega-menu sub-menu is determined by javascript based on the screen width and the calculation was for before the css moves the item. I didn’t find a way to adjust the precious css to correct or a way to correct with more css because the value is dynamic.
I was able to correct with the following javascript and I added it to your child theme functions.phpfunction adjust_mega_menu_submenu_for_aboutus_item_to_be_on_screen() { ?> <script> document.addEventListener('DOMContentLoaded', function() { const menuItem = document.querySelector('#menu-item-287'); const subMenu = document.querySelector('#menu-item-287 .avia_mega3'); function adjustSubMenuPosition() { const viewportWidth = window.innerWidth; const subMenuRect = subMenu.getBoundingClientRect(); const offScreenRight = subMenuRect.right - viewportWidth; if (offScreenRight > 0) { subMenu.style.left =
-${offScreenRight}px
; } else {} } menuItem.addEventListener('mouseenter', function() { subMenu.style.display = 'block'; adjustSubMenuPosition(); }); menuItem.addEventListener('touchstart', function() { subMenu.style.display = 'block'; setTimeout(adjustSubMenuPosition, 200); }); menuItem.addEventListener('mouseleave', function() { subMenu.style.display = 'none'; }); menuItem.addEventListener('touchend', function() { subMenu.style.display = 'none'; }); }); </script> <?php } add_action('wp_footer', 'adjust_mega_menu_submenu_for_aboutus_item_to_be_on_screen', 99);Please clear your browser cache and check.
Best regards,
MikeNovember 19, 2023 at 9:58 am #1425966This reply has been marked as private.November 19, 2023 at 2:17 pm #1425970Hi,
Glad that this helped, but the mega menu width is dynamically created based on the screen width, it’s width is not absolute and is not positioned based on the right edge, but the left edge.
I examined this for quite awhile but unfortunately I don’t have a solution for what you want to achieve, you could try adding another column to the sub-menu.Best regards,
MikeNovember 21, 2023 at 3:18 pm #1426183This reply has been marked as private.November 22, 2023 at 5:11 pm #1426281Hi,
Thanks for your patience, I disabled the script above and added a new mega menu column item call “new item” this makes the mega menu show correctly and the sub-menu items work when you click them, please try to use this new column in your mega menu, changing the name and link to something you can use.Best regards,
MikeNovember 23, 2023 at 1:54 pm #1426341This reply has been marked as private.November 23, 2023 at 3:05 pm #1426344Hi,
I disabled the flex-grow: 1; from this css solution:.avia-menu>ul.av-main-nav li { display: flex; flex-grow: 1; justify-content: center; }
and now the maga menu sub-menu seems to work correctly, at all sizes. Please clear your browser cache and check.
Best regards,
MikeNovember 23, 2023 at 5:42 pm #1426357This reply has been marked as private.November 25, 2023 at 2:15 pm #1426430Hi,
I added this css:.avia-menu>ul.av-main-nav li.menu-item-top-level:not(#menu-item-287) { flex-grow: 1; }
this added the flex-grow to every item except the last one giving us the trouble, I don’t think that it is noticeable because it’s a longer text length and it’s at the end, but this solves the other two issues.
Please clear your browser cache and check.Best regards,
MikeNovember 25, 2023 at 8:43 pm #1426460This reply has been marked as private.November 25, 2023 at 9:30 pm #1426465Hi,
Unfortunately I don’t have a solution for that, there is no way that I can say there won’t be an issue if the nav menu configuration is changed in the future.
You would be better off not using the last snippet and allow the background color to be behind the text. Our menu is not designed for your customization and it seems like we are trying to recreate it from scratch.Best regards,
MikeNovember 28, 2023 at 10:43 am #1426589This reply has been marked as private.November 28, 2023 at 4:54 pm #1426614This reply has been marked as private.November 29, 2023 at 5:44 pm #1426721Hi,
I have not had any new ideas for this, try finish building your menu and see you you find any other related errors, then we can take another look with the finished menu, hopefully some time out of the woods will help us see the trees better :)Best regards,
MikeNovember 29, 2023 at 7:15 pm #1426730This reply has been marked as private.January 5, 2024 at 8:27 pm #1429377This reply has been marked as private.January 6, 2024 at 8:37 pm #1429434Hi,
It looks like for level one & three the menu item gets the class current-menu-item
But not for level two, it gets the class active-parent-item
So try adding this css:#top #header .av-main-nav > li.active-parent-item > a { background-color: #776fb1; }
After applying the css, please clear your browser cache and check.
Best regards,
MikeJanuary 7, 2024 at 1:11 pm #1429454This reply has been marked as private. -
AuthorPosts
- You must be logged in to reply to this topic.