Archived topic
Auto-expand sub-menus on mobile
5 replies · Started by Matt on March 25, 2021
Hi there,
I'd like to set my navigation sub-menus to auto-expand on mobile, but I can't mention in the docs, is there some simple CSS to achieve this?
Many thanks,
Matt
Hi there,
The toggle that opens the submenu is a script.
Are you using an off-canvas menu for mobile? If yes, try this:
You can try creating a Hook Element with hook set to wp_footer. Set the display rule to "Entire site".
You then add this script:
<script>
jQuery( document ).ready( function( $ ) {
$( '#generate-slideout-menu .sub-menu' ).addClass( 'toggled-on' );
$( '#generate-slideout-menu .menu-item-has-children' ).addClass( 'sfHover' );
} );
</script>
Hi Elvin,
I'm just using the standard primary navigation menu - happy to go whichever route makes the most sense, would I be better to replicate as off-canvas?
Many thanks,
Matt
Hi there,
can you share a link to your site and ill take a look at what we can do
Thanks David,
Here you go.
Many thanks,
Matt
Give the CSS here a shot:
https://generatepress.com/forums/topic/make-mobile-menu-look-like-off-canvas-menu/#post-1678051