这是一款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
版权声明
版权说明: 仅限用于学习和研究目的;不得将上述内容用于商业和非法用途!否则一切后果自负。我们非常重视版权问题,如有侵权请邮件至(171373236#qq.com)与我们联系处理,敬请谅解!