navbar example Bulma is not working on mobile Blazor

Viewed 1278

I copied this example navbar from the Bulma website in a Blazor website. On the webpage it is working fine but on mobile the navbar-burger does not respond. Am I missing a vital step in the process? Do I need to do something with .css for example?

<nav class="navbar" role="navigation" aria-label="main navigation">
    <div class="navbar-brand">
        <a class="navbar-item" href="https://bulma.io">
            <img src="https://bulma.io/images/bulma-logo.png" width="112" height="28">
        </a>

        <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
            <span aria-hidden="true"></span>
            <span aria-hidden="true"></span>
            <span aria-hidden="true"></span>
        </a>
    </div>

    <div id="navbarBasicExample" class="navbar-menu">
        <div class="navbar-start">
            <a class="navbar-item">
                Home
            </a>

            <a class="navbar-item">
                Documentation
            </a>

            <div class="navbar-item has-dropdown is-hoverable">
                <a class="navbar-link">
                    More
                </a>

                <div class="navbar-dropdown">
                    <a class="navbar-item">
                        About
                    </a>
                    <a class="navbar-item">
                        Jobs
                    </a>
                    <a class="navbar-item">
                        Contact
                    </a>
                    <hr class="navbar-divider">
                    <a class="navbar-item">
                        Report an issue
                    </a>
                </div>
            </div>
        </div>

        <div class="navbar-end">
            <div class="navbar-item">
                <div class="buttons">
                    <a class="button is-primary">
                        <strong>Sign up</strong>
                    </a>
                    <a class="button is-light">
                        Log in
                    </a>
                </div>
            </div>
        </div>
    </div>
</nav>
2 Answers

This is because Bulma doesn't come with any JavaScript, so you need to toggle the class is-active on both the navbar-burger and the targeted navbar-menu.
There is implementation examples in Bulma navbar documentation, personally I'm using the jQuery implementation which works perfectly :

 $(document).ready(function() {

  // Check for click events on the navbar burger icon
  $(".navbar-burger").click(function() {

      // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
      $(".navbar-burger").toggleClass("is-active");
      $(".navbar-menu").toggleClass("is-active");

  });
});

but there's also a Vanilla Javascript implementation in the docs if you want.

Have you included all scripts and links into index.html? Have you tried hard refresh(Ctrl+F5 or Ctrl+Shirt+R)? Is your Program.cs same as theirs?

If nothing of above worked, can you provide whole codebase? Ideally git or zip.

Related