本文实例为大家分享了bootstrap实现收缩导航条的具体代码,供大家参考,具体内容如下
效果图
贴上我的代码
<Meta charset="utf-8">
<Meta http-equiv="X-UA-Compatible" content="IE=edge">
<Meta name="viewport" content="width=divice-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="external nofollow" rel="stylesheet">
<ul class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a href="index.html" rel="external nofollow" class="navbar-brand">
<span class="glyphicon glyphicon-home">
<button class="navbar-toggle" data-toggle="collspan" data-target="#divNav">
<!--- navbar-toggle:【触发】按钮,会有下拉导航 data-toggle:交替执行某动作,collapse:展开和收缩
data-target:目标对象(自己定义一个名字-->
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<!--按钮里的内容,三条横杠-->
</button>
<!--点击按钮将显示的导航栏目-->
<div id="divNav" class="collapse nav-collapse">
<!--这里的div的id要和上面的data-target值一致,nav-collapse就是折叠导航--->
<ul class="nav navbar-nav">
<li><a href="https://www.jb51.cc/tag/shouye/" target="_blank" class="keywords">首页</a></li>
<li><a href="https://www.jb51.cc/tag/caidan/" target="_blank" class="keywords">菜单</a>1</li>
<li><a href="https://www.jb51.cc/tag/caidan/" target="_blank" class="keywords">菜单</a>2</li>
<li><a href="https://www.jb51.cc/tag/caidan/" target="_blank" class="keywords">菜单</a>3</li>
</ul>
</div>