天天看点

bootstrap 导航条

一、默认的导航条

制作默认的导航条,可分以下几步:

1.在ul里加上(ul class="nav navbar-nav")样式;

2.在ul外加一层div或nav(ps:HTML5新属性),并且添加样式(div class="navbar nabar-default");

bootstrap 导航条
bootstrap 导航条

如图下:

bootstrap 导航条

So easy吧qaq

二、带有表单的导航条

1.在默认导航条的基础上,再一个form。

2.form中应用样式(form class="navbar-form")

bootstrap 导航条
bootstrap 导航条
bootstrap 导航条

擦,写错了,其实我想写打火箭的。。。

三、表单,下拉菜单等冗合的导航条

上一个综合例子,不然一个一个写,小编得coding到天亮,废话少说,直说上料。

bootstrap 导航条
bootstrap 导航条
bootstrap 导航条

咳咳,一般导航都有个大标题,如图下:

bootstrap 导航条

实现步骤:

1.在div里添加样式(div class="navbar-header");

2.在此div添加a标签(a class="navbar-brand");

navbar-brand(品牌)也就是大标题啦!

bootstrap 导航条
bootstrap 导航条

四、反色导航条

反色导航条其实是Bootstrap框架为大家提供的第二种风格的导航条,只是将"navbar-deafult"类名换成"navbar-inverse"。其他不变,见下图:

bootstrap 导航条

个人还是比较喜欢这个风格的,够装逼~

五、固定导航条

顾名思义,其实就是fixed样式,

Bootstrap框架提供了两种固定导航条的方式:

  .navbar-fixed-top:导航条固定在浏览器窗口顶部

  .navbar-fixed-bottom:导航条固定在浏览器窗口底部

使用方法很简单,只需要在制作导航条最外部容器navbar上追加对应的类名即可

bootstrap 导航条
bootstrap 导航条

六、响应式导航条

bootstrap 导航条
bootstrap 导航条

我这是套的反色导航条的,现在分别看下宽屏和窄屏的显示效果,如图下:

bootstrap 导航条
bootstrap 导航条

<button>里面是窄屏右上角的按钮,span标签是三道杠,

现在说一下上面代码中第5行,data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar",这都什么跟什么啊,我这逐一介绍一下;

data-toggle="collapse"     代表     告诉js要什么事件来触发,此处的coolapse为“伸展折叠”;

data-target="#navbar"     代表     谁要以伸展折叠的方式来展示,绑定的是ID;

aria-expanded="false"      代表     是否展开,false。

继续阅读