There is an easier way! Before I get to this, there seem to be a few issues with your Html.
First edition. You do not have a navigation structure created as documentation suggests. If you replace nav-left
with navbar-brand
, it will take care of some of your Html for you. In your sample code, you have the nav-item
logo inside nav-left
. navbar-brand
does just that. What you did here may work, but I'm not sure what it will do. From the documentation:
" navbar-brand
left side, always visible, which usually contains a logo and optionally some links or icons"
So, if you select this to the container level and inside it, you can just put your logo in the first navbar-item
. The next is to pull out the navbar-burger inside of the
navigation mark.
" navbar-burger
is a hamburger menu that only appears on a mobile device. It should appear as the last child of the navbar brand. "
After configuration, you will want to place the menu items that you want to collapse inside navbar-menu
. This container should be the navbar-brand
brother, so they should be on the same level together. So your code (inside your div container) should look like LIKE SO:
<nav class="navbar"> <div class="navbar-brand"> <a class="navbar-item" href="/"> <img src="../assets/icon.png" alt="something"> </a> <div class="navbar-burger burger" data-target="Options"> <span></span> <span></span> <span></span> </div> </div> <div class="navbar-menu" id="Options"> <div class="navbar-end"> <a class="nav-item" href="/about">About</a> <a class="nav-item" href="/path">Path</a> <a class="nav-item" href="/blog">Blog</a> </div> </div> </nav>
Last part of the puzzle: you have to set the data-target
your hamburger to the navbar-menu
identifier. It is not clear what they say in the documents. In any case, after making these changes, the javascript code from the documentation should work!
I understand that this question was asked by many moons ago, but I hope this helps someone.
Bulma docs http://bulma.io/documentation/components/navbar/
source share