How to Fix the Zakra Theme Mobile Menu Scroll Bar Issue
Content
Many users of the Zakra theme have encountered a specific visual bug on their mobile and tablet sites: an unnecessary scroll bar appears inside the mobile menu when expanding submenus. This guide will explain why this happens and provide a straightforward CSS fix to clean up your mobile navigation.
The Problem: Unwanted Mobile Menu Scroll Bar
When you click the hamburger menu on a tablet or mobile device and then tap a plus (+) icon to expand a submenu (e.g., for items like 'About' or 'Learn'), a vertical scroll bar appears alongside the list of sub-items. This scroll bar is often unnecessary because the submenu isn't long enough to require scrolling, and it disrupts the clean design of the navigation.
Why This Happens
This behavior is controlled by the Zakra theme's CSS. The theme applies a set of styles to expanded submenus that includes a fixed maximum height and enables scrolling, regardless of whether it's needed. The specific CSS code that causes this is:
.tg-mobile-navigation li.page_item_has_children.submenu--show > ul,
.tg-mobile-navigation li.menu-item-has-children.submenu--show > ul {
max-height: 500px;
visibility: visible;
overflow-y: scroll; /* This property forces the scroll bar */
}
The overflow-y: scroll; rule instructs the browser to always display a scroll bar for that element, even if the content does not overflow its container.
How to Fix It
The most effective solution is to override this CSS rule by adding a small snippet of code to your site's Additional CSS section. This will change the behavior to only show a scroll bar if the submenu content is actually long enough to require it.
- In your WordPress dashboard, navigate to Appearance > Customize.
- Click on the Additional CSS tab.
- Copy and paste the following CSS code into the provided text area:
.tg-mobile-navigation li.page_item_has_children.submenu--show > ul, .tg-mobile-navigation li.menu-item-has-children.submenu--show > ul { overflow-y: auto; } - Click Publish to save your changes.
What this fix does: Changing overflow-y: scroll; to overflow-y: auto; tells the browser to intelligently display a scroll bar only when the content inside the submenu exceeds the available space. If the submenu is short, no scroll bar will appear.
Alternative: Remove Scroll Bar Completely
If you are certain your submenus will never be long enough to need scrolling, you can hide the scroll bar entirely. To do this, use the following code in the Additional CSS section instead:
.tg-mobile-navigation li.page_item_has_children.submenu--show > ul,
.tg-mobile-navigation li.menu-item-has-children.submenu--show > ul {
overflow-y: hidden;
}
Note of caution: Use the hidden value carefully. If a submenu has more items than can fit on the screen, they will be cut off and inaccessible to users.
Troubleshooting Tips
- Clear your cache: After making CSS changes, always clear any caching plugins you have installed and your browser cache to see the changes take effect immediately.
- Check on mobile: Use your browser's developer tools to simulate a mobile device or physically check your site on a phone/tablet to confirm the fix is working.
This simple CSS adjustment should resolve the unwanted scroll bar issue and provide a smoother experience for your mobile visitors.
Related Support Threads Support
-
Hide breadcrumbs and add auto scroll to contenthttps://wordpress.org/support/topic/hide-breadcrumbs-and-add-auto-scroll-to-content/
-
top bar dissapears in mobile versionhttps://wordpress.org/support/topic/top-bar-dissapears-in-mobile-version/
-
It spoils the appearance of the site. Move it from top to bottom.https://wordpress.org/support/topic/it-spoils-the-appearance-of-the-site-move-it-from-top-to-bottom/
-
Dropdown toggle indicators (arrows) on tablets – request for clarificationhttps://wordpress.org/support/topic/dropdown-toggle-indicators-arrows-on-tablets-request-for-clarification/
-
Dropdown menu in header top barhttps://wordpress.org/support/topic/dropdown-menu-in-header-top-bar/
-
Top Bar disappears on mobile Zakra 3.0.6/WP 6.4.2https://wordpress.org/support/topic/top-bar-disappears-on-mobile-zakra-3-0-6-wp-6-4-2/
-
Breadcrumbs misaligned in mobile screen – Zakra Themehttps://wordpress.org/support/topic/breadcrumbs-misaligned-in-mobile-screen-zakra-theme/
-
[NSFW] navigation.min.js Does not use passive listeners – pagespeed web vitalshttps://wordpress.org/support/topic/navigation-min-js-does-not-use-passive-listeners-pagespeed-web-vitals-2/
-
mobile menu toggle(X) is hard to clickhttps://wordpress.org/support/topic/mobile-menu-togglex-is-hard-to-click/
-
Make the menu in the header remain abovehttps://wordpress.org/support/topic/make-the-menu-in-the-header-remain-above/
-
Move the Woocommerce cart outside the menu when in mobile modehttps://wordpress.org/support/topic/move-the-woocommerce-cart-outside-the-menu-when-in-mobile-mode/
-
Remove scroll bar in mobile menu drop downhttps://wordpress.org/support/topic/remove-scroll-bar-in-mobile-menu-drop-down/
-
Scroll Animationhttps://wordpress.org/support/topic/scroll-animation-2/
-
Add user greetings to mobile tg-mobile-navigationhttps://wordpress.org/support/topic/add-user-greetings-to-mobile-tg-mobile-navigation/
-
Menu Item Scrolls down homepagehttps://wordpress.org/support/topic/menu-item-scrolls-down-homepage/