Bulma导航栏汉堡包菜单不展开

时间:2019-02-24 02:05:56

标签: bulma hamburger-menu

我复制了Bulmabasic starter templatebasic navbar。但是,当我单击汉堡菜单时,没有任何反应:(。我是否缺少任何东西?您可以try it in my jsfiddle

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hello Bulma!</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.4/css/bulma.min.css">
    <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
  </head>
  <body>
    <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>
  <section class="section">
    <div class="container">
      <h1 class="title">
        Hello World
      </h1>
      <p class="subtitle">
        My first website with <strong>Bulma</strong>!
      </p>
    </div>
  </section>
  </body>
</html>

1 个答案:

答案 0 :(得分:1)

https://bulma.io/documentation/components/navbar/

“ Bulma软件包不附带任何JavaScript。 但是,这是一个实现示例,该示例在Vanilla Javascript中同时切换了navbar-burger和目标navbar-menu上的活动类。”

添加一些js:

/**
 * my TestCase Class
 */
class TestCase {

    doesntWorkA(/** String */ str) /** Number */ {
        return 5;
    }

    doesntWorkB(/** @type {String} */ str) /** @type {Number} */ {
        return 5;
    }


    /**
    * @param {String} str
    * @return {Number}
    */
    works(str) {
        return 5;
    }
}