Bootstrap4多级导航菜单插件


源码介绍

简要教程

这是一款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



点赞(0) 打赏

立即下载

点击下载

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部