Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Make secondary navigation scroll horizontally and hide scrollbars

  • I want to be able to scroll the secondary menu horizontally without it wrapping to a new line in smaller screen and also hide the scrollbars when this happens. Also, when the menu is scrollable I want to be able to scroll left and right and be able to see the menu from edge to edge. I tried a few things but couldn’t make it, can you help with CSS?

    It’s the menu below the header in the attached URL. Menu is hidden on mobile.

  • Hi George,

    Can you try this CSS?:

    @media (max-width: 768px){
        nav#secondary-navigation .inside-navigation .main-nav ul{
            display: flex;
            flex-wrap: nowrap;
            width: fit-content;
        }
        nav#secondary-navigation .inside-navigation .main-nav{
            overflow-x: scroll;
        }
        nav#secondary-navigation .inside-navigation .main-nav ul li{
            white-space:nowrap;
        }
    }
  • Ok, thanks for the pointers, Fernando. That bit of CSS worked for me:

    /* Add horizontal scrolling */
    nav#secondary-navigation .inside-navigation .main-nav ul {
    	display: flex;
    	flex-wrap: nowrap;
    	width: fit-content;
    }
    nav#secondary-navigation .inside-navigation .main-nav {
    	overflow-x: scroll;
    }
    nav#secondary-navigation .inside-navigation .main-nav ul li {
    	white-space:nowrap;
    }
    
    /* Hide the scrollbar */
    nav#secondary-navigation .inside-navigation .main-nav {
      overflow: auto;
      -ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
      scrollbar-width: none; /* Hide scrollbar for Firefox */
      -webkit-overflow-scrolling: touch; /* Add smooth scrolling for Webkit browsers */
    }
    
    /* Hide scrollbar for Chrome, Safari, and Opera */
    nav#secondary-navigation .inside-navigation .main-nav::-webkit-scrollbar {
      display: none; /* Hide scrollbar for Chrome, Safari, and Opera */
    }
  • You’re welcome, George!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.