Site logo

Archived topic

Mobile Navigation Styling

5 replies · Started by Austin on August 7, 2021

Viewing posts 1–6 of 6

Hi,

Is it possible to create a mobile menu like the one used on apple.com? It is similar to the standard slide down style of generatepress (not the off-canvas option). However, instead of pushing the page content down it overlays the content and goes to the bottom of the screen.

Screen shot

My website

Thanks

Hi there,

try adding this CSS:

@media(max-width: 800px) {
    .main-navigation:not(.slideout-navigation):not(.toggled) .main-nav>ul {
        display: block;
    }

    #masthead #site-navigation {
        height: auto;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in;
        position: fixed;
        top: 58px;
        left: 0;
        right: 0;
        bottom: 0;
        margin-top: 0;
        background-color: #fff;
        z-index: 1000;
        pointer-events: none;
    }
    /* adjust positon when admin bar is present */
    .admin-bar #masthead #site-navigation {
        top: 90px;
    }
    #masthead #site-navigation.toggled {
        max-height: 1000px;
        pointer-events: initial;
        overflow-y: scroll;
    }

    .mobile-menu-open body {
        overflow: hidden !important;
    }

    .main-navigation .main-nav > ul > li {
        border-bottom: 1px solid #ccc;
    }
    /* Mobile search field */
    .mobile-menu-open .navigation-search {
        position: static;
        pointer-events: initial;
        visibility: visible;
        opacity: 1;
        padding: 10px;
    }
    .main-navigation .navigation-search input[type="search"] {
        border: 1px solid #ccc;
        border-radius: 10px;
        background-color: #f1f1f1;
    }
    .mobile-menu-open .search-item {
        opacity: 0;
        pointer-events: none;
    }
}

Hey David,

I appreciate the help and it looks great. Would it be possible to remove lines under every sub menu item, and just keep the line at the end of the expanded parent menu? Also, does it require an off-canvas menu to insert the search box into the menu?

Thanks for the help

Try the revised CSS above.

Awesome man. Appreciate the help.

You're welcome!

This archived topic is closed to new replies.