码迷,mamicode.com
首页 > 其他好文 > 详细

bootstrap导航

时间:2017-05-03 14:32:00      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:span   标记   方向   trap   ros   垂直   样式   order   port   

导航
Bootstrap 中的导航组件都依赖同一个 .nav 类,状态类也是共用的。

改变修饰类能够改变样式。
标签页
注意 .nav-tabs 类依赖 .nav 基类

代码例如以下

<!DOCTYPE html>
<html ng-app="UserInfoCtrl">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>bootstrap导航</title>
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
     <script src="js/jquery-1.11.2.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
  </head>
  <body>
   <ul class="nav nav-tabs">
  <li role="presentation" class="active"><a href="#">Home</a></li>
  <li role="presentation"><a href="#">Profile</a></li>
  <li role="presentation"><a href="#">Messages</a></li>
</ul>
  </body>
</html>
效果图

技术分享

胶囊式标签页
HTML 标记同样,但使用 .nav-pills 类:
代码例如以下

<!DOCTYPE html>
<html ng-app="UserInfoCtrl">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>bootstrap导航</title>
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
     <script src="js/jquery-1.11.2.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
  </head>
  <body>
  <ul class="nav nav-pills">
  <li role="presentation" class="active"><a href="#">Home</a></li>
  <li role="presentation"><a href="#">Profile</a></li>
  <li role="presentation"><a href="#">Messages</a></li>
  </ul>
  </body>
</html>
效果图

技术分享

胶囊是标签页也是能够垂直方向堆叠排列的。

仅仅需加入 .nav-stacked 类。
代码例如以下

<!DOCTYPE html>
<html ng-app="UserInfoCtrl">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>bootstrap导航</title>
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
     <script src="js/jquery-1.11.2.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
  </head>
  <body>
  <ul class="nav nav-pills nav-stacked">
  <li role="presentation" class="active"><a href="#">Home</a></li>
  <li role="presentation"><a href="#">Profile</a></li>
  <li role="presentation"><a href="#">Messages</a></li>
  </ul>
  </body>
</html>
效果图

技术分享

两端对齐的标签页
在大于 768px 的屏幕上,通过 .nav-justified 类能够非常easy的让标签页或胶囊式标签呈现出同等宽度。在小屏幕上。导航链接呈现堆叠样式。


两端对齐的导航条导航链接已经被弃用了。
代码例如以下

<!DOCTYPE html>
<html ng-app="UserInfoCtrl">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>bootstrap导航</title>
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
     <script src="js/jquery-1.11.2.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
  </head>
  <body>
  <ul class="nav nav-tabs nav-justified">
  <li role="presentation" class="active"><a href="#">Home</a></li>
  <li role="presentation"><a href="#">Profile</a></li>
  <li role="presentation"><a href="#">Messages</a></li>
  </ul>
  </body>
</html>

效果图

技术分享

禁用的链接
对不论什么导航组件(标签页、胶囊是标签页)。都能够加入 .disabled 类,从而实现链接为灰色且没有鼠标悬停效果
代码例如以下

<!DOCTYPE html>
<html ng-app="UserInfoCtrl">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>bootstrap导航</title>
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
     <script src="js/jquery-1.11.2.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
  </head>
  <body>
  <ul class="nav nav-pills">
  <li role="presentation" class="active"><a href="#">Home</a></li>
  <li role="presentation"><a href="#">Profile</a></li>
  <li role="presentation"><a href="#">Messages</a></li>
  <li role="presentation" class="disabled"><a href="#">Disabled link</a></li>
  </ul>
  </body>
</html>

效果图

技术分享

加入下拉菜单
用一点点额外 HTML 代码并增加下拉菜单插件的 JavaScript 插件就可以。


带下拉菜单的标签页
代码例如以下

<!DOCTYPE html>
<html ng-app="UserInfoCtrl">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>bootstrap导航</title>
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
     <script src="js/jquery-1.11.2.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
  </head>
  <body>

  <ul class="nav nav-tabs">
  <li role="presentation" class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
      Dropdown <span class="caret"></span>
    </a>
    <ul class="dropdown-menu" role="menu">
      <li role="presentation" class="active"><a href="#">Home</a></li>
       <li role="presentation"><a href="#">Profile</a></li>
      <li role="presentation"><a href="#">Messages</a></li>
    </ul>
      <li role="presentation"><a href="#">Profile</a></li>
      <li role="presentation"><a href="#">Profile</a></li>
  </li>
</ul>
  </body>
</html>
效果图

技术分享

带下拉菜单的胶囊式标签页
代码例如以下

<!DOCTYPE html>
<html ng-app="UserInfoCtrl">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>bootstrap导航</title>
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
     <script src="js/jquery-1.11.2.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
  </head>
  <body>

  <ul class="nav nav-pills">
  <li role="presentation" class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
      Dropdown <span class="caret"></span>
    </a>
    <ul class="dropdown-menu" role="menu">
      <li role="presentation" class="active"><a href="#">Home</a></li>
       <li role="presentation"><a href="#">Profile</a></li>
      <li role="presentation"><a href="#">Messages</a></li>
    </ul>
      <li role="presentation"><a href="#">Profile</a></li>
      <li role="presentation"><a href="#">Profile</a></li>
  </li>
</ul>
  </body>
</html>

效果图

技术分享


注:本文来自java教程网。很多其它学习资料尽在java教程网

bootstrap导航

标签:span   标记   方向   trap   ros   垂直   样式   order   port   

原文地址:http://www.cnblogs.com/lxjshuju/p/6801582.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!