Visualizzazione 0 filoni di risposte
Visualizzazione 0 filoni di risposte
- Devi essere connesso per rispondere a questo topic.
Email: info@wpitaly.it
Home › Forum › Problemi Vari con WP › Problema sottomenu responsive
Ciao a tutti, ho un problema con il codice navigation.js per la creazione del menu responsive.
In modalità desktop, il menu con relativo sottomenu viene visualizzato correttamente. Quando, invece, passo alla visualizzazione ridimensionata, il sottomenu compare tutto sballato. Quello che vorrei è rendere il sottomenu espandibile, come in questo esempio.
Intanto, vi lascio il codice navigation.js cosଠpotete dirmi se ho sbagliato e devo modificare qualcosa.
/**
* navigation.js
*
* Handles toggling the navigation menu for small screens.
*/
( function() {
var container, button, menu;
container = document.getElementById( 'site-navigation' );
if ( ! container ) {
return;
}
button = container.getElementsByTagName( 'button' )[0];
if ( 'undefined' === typeof button ) {
return;
}
menu = container.getElementsByTagName( 'ul' )[0];
// Hide menu toggle button if menu is empty and return early.
if ( 'undefined' === typeof menu ) {
button.style.display = 'none';
return;
}
menu.setAttribute( 'aria-expanded', 'false' );
if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
menu.className += ' nav-menu';
}
button.onclick = function() {
if ( -1 !== container.className.indexOf( 'toggled' ) ) {
container.className = container.className.replace( ' toggled', '' );
button.setAttribute( 'aria-expanded', 'false' );
menu.setAttribute( 'aria-expanded', 'false' );
} else {
container.className += ' toggled';
button.setAttribute( 'aria-expanded', 'true' );
menu.setAttribute( 'aria-expanded', 'true' );
}
};
} )();
grazie!
WPItaly - Copyright Creative Commons: CC BY-NC-SA 4.0