Bootstrap4多级导航菜单插件

当前位置:主页 > jQuery库 > 菜单和导航 > Bootstrap4多级导航菜单插件
Bootstrap4多级导航菜单插件
分享:

    插件介绍

    这是一款Bootstrap4多级导航菜单插件。该插件扩展了原生bootstrap4的navbar,可生成多级导航菜单,并添加炫酷的CSS3动画效果。

    浏览器兼容性

    浏览器兼容性
    时间:01-15
    阅读:
简要教程

这是一款Bootstrap4多级导航菜单插件。该插件扩展了原生bootstrap4的navbar,可生成多级导航菜单,并添加炫酷的CSS3动画效果。

使用方法

在页面中引入jquery.min.js、bootstrap4相关文件,以及bootnavbar.css、bootnavbar.js和animate.css文件。

<link rel="stylesheet" href="css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/bootnavbar.css"/>
<link rel="stylesheet" href="css/animate.css"/>
<script  src="js/jquery.min.js"></script>        
<script  src="js/bootstrap.min.js"></script>        
<script  src="js/bootnavbar.js"></script>        
    
HTML结构

该导航菜单的HTML结构如下。

<nav class="navbar navbar-expand-lg navbar-light bg-light" id="main_navbar">
  <a class="navbar-brand" href="#">Navbar</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
            aria-haspopup="true" aria-expanded="false">
            Dropdown
        </a>
        <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
          <li><a class="dropdown-item" href="#">Action</a></li>
          <li><a class="dropdown-item" href="#">Another action</a></li>
          <div class="dropdown-divider"></div>
          <li></li><a class="dropdown-item" href="#">Something else here</a></li>
          <li class="nav-item dropdown">
            <a class="dropdown-item dropdown-toggle" href="#" id="navbarDropdown1" role="button" data-toggle="dropdown"
                aria-haspopup="true" aria-expanded="false">
              Dropdown
            </a>
            <ul class="dropdown-menu" aria-labelledby="navbarDropdown1">
              <li><a class="dropdown-item" href="#">Action</a></li>
              <li><a class="dropdown-item" href="#">Another action</a></li>
              <div class="dropdown-divider"></div>
              <li></li><a class="dropdown-item" href="#">Something else here</a></li>
              <li class="nav-item dropdown">
                <a class="dropdown-item dropdown-toggle" href="#" id="navbarDropdown2" role="button" data-toggle="dropdown"
                    aria-haspopup="true" aria-expanded="false">
                  Dropdown
                </a>
                <ul class="dropdown-menu" aria-labelledby="navbarDropdown2">
                  <li><a class="dropdown-item" href="#">Action</a></li>
                  <li><a class="dropdown-item" href="#">Another action</a></li>
                  <div class="dropdown-divider"></div>
                  <li></li><a class="dropdown-item" href="#">Something else here</a></li>
                </ul>
              </li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
  </div>
</nav>
    
初始化插件

在页面DOM原生加载完毕之后,通过下面的方法来初始化该导航菜单插件。

$(function () {
  $('#main_navbar').bootnavbar();
})
    

该Bootstrap4多级导航菜单插件的github网址为:https://github.com/kmlpandey77/bootnavbar