Last active
December 17, 2024 11:58
-
-
Save diggeddy/d536a711522f37fd54e6118a18d80f26 to your computer and use it in GitHub Desktop.
Create a sub menu item container with action hook
@DavidKeevis Thanks for providing the alternate CSS, Seems like your solution prevents other menu items from being selected while a submenu is open. I was also wondering if there was a way to set the sub menu full-width.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update after some experimentation. Recommend considering this CSS approach:
.gp_mega_item {
position: static !important;
}
#site-navigation .gp_mega_item .sub-menu.custom-sub-menu {
width: max-content;
top: 0;
right: 0;
box-shadow: none !important;
background-color: transparent;
}
This provides the basic environment for the element to display in and shifts all the width control to the element. In the element, set the outer container width in px, em, rem - whatever units you're working in (i.e. 1200px). If the Set up desired width in tablet (i.e. 720px). Hide on mobile in the element's Advanced section. May wish to consider compensating for the header padding that's set in the customizer. Can tinker with the margin values also, especially top margin. Keeps everything nicely packaged and easy to plug into another site.
This also lets you to easily use flex containers inside the element for positioning and responsiveness which takes this to a whole higher level.