-
fcacic
Hello there! We are making a new company website, and we decided to use a mega menu. I followed the tutorial https://docs.generatepress.com/article/building-simple-mega-menu/
Everything looks fine, I used the 3 column css:
nav .main-nav .mega-menu.mega-menu-col-3>ul>li {
width: 33.3333%;
}Here is the pictures: https://imgur.com/a/HNG1rbb
The menu is completely fine look wise, but in order to get Branding, SEO Optimizacija and Marketing consulting where they are positionally in the first column, I needed to make them children of Web stranice, which I don’t want.
They should be the same level div, as you can see by their font size. So basically everything looks as it should, but I got the solution the “wrong way”, since this way they are essentially grandchildren items but in truth they should be just children if I’m making any sense.
So is there any way I could put them under Web stranice without making them the children of Web stranice?
Thanks in advance and sorry for the lackluster explanation 😀
-
Hi there,
tricky one, as the sub menus are what define the individual columns.
However, we may be able to get around that with a different approach.If you can construct the menu without the mega menu, and in the structure your require.
Then let me have access to the site so i can see the menu item ill provide some other CSS for it. -
fcacic
Yes ofcourse!
I made the structure as its supposed to be, I also commented out the Mega menu css, if you need to enable it feel free!
-
Ok, so i had to re-order the menu items, as those 3 x child items had to come immediately after the first parent menu.
And in the Customizer CSS, i kept your current CSS and left it commented out.
And before that i added a different set of CSS.
In that CSS i commented this section:/* menu columns */ nav .main-nav .mega-menu>ul { position: absolute; width: 100%; right: 0 !important; display: block; column-count: 3; } nav .main-nav .mega-menu>ul>li:nth-child(5), nav .main-nav .mega-menu>ul>li:nth-child(6) { break-before: column; } /*-- menu columns end --*/
First we use
column-count: 3;
CSS property to create the 3 columns.
An then we tell which parent LI’s need to break toa new column.
In the example its the 5th and 6th menu items. -
fcacic
Works like a charm, thank you so much David! One more tiny thing, is it possible to add a smooth transition to the mega menu appearance, so that when we hover on the menu item, the menu smoothly appears? Thank you again for the fix!
-
Within the
@media
query you could add this CSS at the end:nav .main-nav .mega-menu>ul { left: 0 !important; height: auto !important; max-height: 0; transition: all 0.3s ease-in; } nav .main-nav .mega-menu:hover>ul { max-height: 400px; }
Adjust the
max-height: 400px;
to suit the need. -
fcacic
Thank you David, works amazing. I just realised there is a slight issue where I can’t click on child items under the first menu item in the mega menu, as far as I can tell the structure is the same as the other ones?
-
fcacic
Nevermind, I managed to correct it with some css, thank you for all the feedback, I will mark the topic as resolved now.
-
You’re welcome!
- You must be logged in to reply to this topic.