How to create Mega Menu in generatepress without plugin ?

Hitori Tech
  1. copy the below code and paste it to Appearance > customize > additional css and paste it.  
  2. Add classes to the Mega Menu items as show in example below

Mega Menu In GeneratePress

Natively Generatepress Does Not support mega menu functionality but there is way that you can create a mega menu in generatepress theme for this all you need add some additional css code and some classes to the menu items 

Step 1 : copy the below code and paste it to Appearance > customize > additional css and paste it.  

@media (min-width: 769px) {
    nav .main-nav .mega-menu {
        position: static;
    }
nav .main-nav .mega-menu > ul {
        position: absolute;
        width: 100%;
        left: 0 !important;
        display: flex;
        flex-wrap: wrap;
    }
nav .main-nav .mega-menu > ul > li > a {
        font-weight: bold;
    }
nav .main-nav .mega-menu>ul>li {
        display: inline-block;
        width: 25%;
        vertical-align: top;
    }
nav .main-nav .mega-menu.mega-menu-col-2>ul>li {
        width: 50%;
    }
 nav .main-nav .mega-menu.mega-menu-col-3>ul>li {
        width: 33.3333%;
    }
nav .main-nav .mega-menu.mega-menu-col-5>ul>li {
        width: 20%;
    }
nav .main-nav .mega-menu > ul > li:hover > a,
    nav .main-nav .mega-menu > ul > li:focus > a,
    nav .main-nav .mega-menu > ul > li[class*="current-"] > a,
    nav .main-nav .mega-menu ul ul {
        background-color: transparent !important;
        color: inherit;
    }
<!-- wp:code -->
<pre class="wp-block-code"><code>@media (min-width: 769px) {
    nav .main-nav .mega-menu {
        position: static;
    }
nav .main-nav .mega-menu > ul {
        position: absolute;
        width: 100%;
        left: 0 !important;
        display: flex;
        flex-wrap: wrap;
    }
nav .main-nav .mega-menu > ul > li > a {
        font-weight: bold;
    }
nav .main-nav .mega-menu>ul>li {
        display: inline-block;
        width: 25%;
        vertical-align: top;
    }
nav .main-nav .mega-menu.mega-menu-col-2>ul>li {
        width: 50%;
    }
 nav .main-nav .mega-menu.mega-menu-col-3>ul>li {
        width: 33.3333%;
    }
nav .main-nav .mega-menu.mega-menu-col-5>ul>li {
        width: 20%;
    }
nav .main-nav .mega-menu > ul > li:hover > a,
    nav .main-nav .mega-menu > ul > li:focus > a,
    nav .main-nav .mega-menu > ul > li&#91;class*="current-"] > a,
    nav .main-nav .mega-menu ul ul {
        background-color: transparent !important;
        color: inherit;
    }
nav .main-nav .mega-menu ul .sub-menu {
        position: static;
        display: block;
        opacity: 1;
        visibility: visible;
        width: 100%;
        box-shadow: 0 0 0;
        left: 0;
        height: auto;
        pointer-events: auto;
        transform: scale(1);
    }
nav .main-nav .mega-menu ul.toggled-on .sub-menu {
        pointer-events: auto;
    }
nav .main-nav .mega-menu .sub-menu .menu-item-has-children .dropdown-menu-toggle {
        display: none;
    }
}


Step 2:  Add classes to the Mega Menu items as show in example below

Mega Menu

You need to go to appearance > menu and add classes to parent item and add classes to only parent item add sub item below it 

If you are not able to see classes in menu item option you can enable it from the screen option.

This will have a mega menu enabled to your parent  after this you need to columns classes by default it is set 4 columns

You can change it by adding classes to your parent items.

.Mega-menu-col-2
.Mega-menu-col-3
.Mega-menu-col-4
.Mega-menu-col-5

 Here is official documentation link form genratepress

Leave a Comment