Mobile menu toggle
Bulma changes the navbar
into a mobile menu with a burger icon at a specific breakpoint. In order to make it workable you need to add some JavaScript code. You will create an event listener and toggle the is-active
class. You also have to toggle the burger element’s class to is-active
to change the burger icon to close the icon.
var
burger
=
document
.
querySelector
(
'.burger'
);
var
menu
=
document
.
querySelector
(
'.navbar-menu'
)
if
(
burger
!==
null
)
{
burger
.
addEventListener
(
'click'
,
function
()
{
burger
.
classList
.
toggle
(
'is-active'
);
menu
.
classList
.
toggle
(
'is-active'
);
});
}
`