Bootstrap组件之下拉菜单,多级菜单及按钮布局方法实例


Posted in Javascript onMay 25, 2017

本文实例讲述了Bootstrap组件之下拉菜单,多级菜单及按钮布局方法。分享给大家供大家参考,具体如下:

下拉菜单

菜单: ,dropdown(.dropup改变这个是上显示)   data-toggle="dropdown" (激活文本处)      .dropdown-menu   .pull-left   .pull-right
按钮组:.btn-group(各种类为btn的标签集合)    .btn-toolbar(按钮导航条)  .btn-group-vertical   .btn-mini  .btn-small   .btn-large   .nav-pills(胶囊样式)
导航:  .nav   .nav-tabs  .pull-right   .disabled     .nav-stacked(堆叠)  .nav-list     data-toggle="tab"    .tabbable(容器)   .tabs-left (right  , below)   .tab-content

注意: .dropdown-submenu(多级导航中,可能bootstrap中没有)自行添加:

<style type="text/css">
  .dropdown-submenu {
   position: relative;
  }
  .dropdown-submenu > .dropdown-menu {
   top: 0;
   left: 100%;
   margin-top: -6px;
   margin-left: -1px;
   -webkit-border-radius: 0 6px 6px 6px;
   -moz-border-radius: 0 6px 6px;
   border-radius: 0 6px 6px 6px;
  }
  .dropdown-submenu:hover > .dropdown-menu {
   display: block;
  }
  .dropdown-submenu > a:after {
   display: block;
   content: " ";
   float: right;
   width: 0;
   height: 0;
   border-color: transparent;
   border-style: solid;
   border-width: 5px 0 5px 5px;
   border-left-color: #ccc;
   margin-top: 5px;
   margin-right: -10px;
  }
  .dropdown-submenu:hover > a:after {
   border-left-color: #fff;
  }
  .dropdown-submenu.pull-left {
   float: none;
  }
  .dropdown-submenu.pull-left > .dropdown-menu {
   left: -100%;
   margin-left: 10px;
   -webkit-border-radius: 6px 0 6px 6px;
   -moz-border-radius: 6px 0 6px 6px;
   border-radius: 6px 0 6px 6px;
  }
</style>

添加这段css即可使.dropdown-submenu有效

实现菜单样式:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script type="text/javascript" src="bootstrap-3.3.6/js/jquery.cyan1.js"></script>
<script type="text/javascript" src="bootstrap-3.3.6/js/dropdown.js"></script>
<link rel="stylesheet" href="bootstrap-3.3.6/dist/css/bootstrap.min.css" rel="external nofollow" />
 <style type="text/css">
  .dropdown-submenu {
   position: relative;
  }
  .dropdown-submenu > .dropdown-menu {
   top: 0;
   left: 100%;
   margin-top: -6px;
   margin-left: -1px;
   -webkit-border-radius: 0 6px 6px 6px;
   -moz-border-radius: 0 6px 6px;
   border-radius: 0 6px 6px 6px;
  }
  .dropdown-submenu:hover > .dropdown-menu {
   display: block;
  }
  .dropdown-submenu > a:after {
   display: block;
   content: " ";
   float: right;
   width: 0;
   height: 0;
   border-color: transparent;
   border-style: solid;
   border-width: 5px 0 5px 5px;
   border-left-color: #ccc;
   margin-top: 5px;
   margin-right: -10px;
  }
  .dropdown-submenu:hover > a:after {
   border-left-color: #fff;
  }
  .dropdown-submenu.pull-left {
   float: none;
  }
  .dropdown-submenu.pull-left > .dropdown-menu {
   left: -100%;
   margin-left: 10px;
   -webkit-border-radius: 6px 0 6px 6px;
   -moz-border-radius: 6px 0 6px 6px;
   border-radius: 6px 0 6px 6px;
  }
 </style>
</head>
<body>
<ul class="nav nav-pills">
<li class="dropdown">
 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="btn btn-large" data-toggle="dropdown">cyan111<i class="caret"></i></a>
 <ul class="dropdown-menu">
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >qiao1</a></li>
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >qiao2</a></li>
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >qiao3</a></li>
 </ul>
</li>
<li class="dropdown">
 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="btn btn-large" data-toggle="dropdown">cyan222<i class="caret"></i></a>
 <ul class="dropdown-menu">
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >gao1</a></li>
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >gao2</a></li>
  <li class="dropdown-submenu"> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >gao3</a>
    <ul class="dropdown-menu pull-right">
     <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >qiao1</a></li>
     <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >qiao2</a></li>
     <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >qiao3</a></li>
    </ul>
  </li>
 </ul>
</li>
</ul>
<div class="dropup">
 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="btn btn-large" data-toggle="dropdown">cyan333<i class="caret"></i></a>
 <ul class="dropdown-menu">
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >chao1</a></li>
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >chao2</a></li>
  <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >chao3</a></li>
 </ul>
</div>
</body>
</html>

结果:

Bootstrap组件之下拉菜单,多级菜单及按钮布局方法实例

Javascript 相关文章推荐
javascript new 需不需要继续使用
Jul 02 Javascript
跨浏览器的事件对象介绍
Jun 27 Javascript
jQuery实现统计复选框选中数量
Nov 24 Javascript
通过伪协议解决父页面与iframe页面通信的问题
Apr 05 Javascript
freemarker判断对象是否为空的方法
Aug 13 Javascript
谈谈AngularJs中的隐藏和显示
Dec 09 Javascript
JS中使用mailto实现将用户在网页中输入的内容传递到本地邮件客户端
Oct 08 Javascript
JS调用打印机功能简单示例
Nov 28 Javascript
Easyui和zTree两种方式分别实现树形下拉框
Aug 04 Javascript
Router解决跨模块下的页面跳转示例
Jan 11 Javascript
JavaScript实现汉字转换为拼音及缩写的方法示例
Mar 28 Javascript
Vue起步(无cli)的啊教程详解
Apr 11 Javascript
vue-router实现webApp切换页面动画效果代码
May 25 #Javascript
Angular 2.x学习教程之结构指令详解
May 25 #Javascript
bootstrap动态添加面包屑(breadcrumb)及其响应事件的方法
May 25 #Javascript
js获取一组日期中最近连续的天数
May 25 #Javascript
AngularJs定时器$interval 和 $timeout详解
May 25 #Javascript
slideToggle+slideup实现手机端折叠菜单效果
May 25 #Javascript
Bootstrap实现的标签页内容切换显示效果示例
May 25 #Javascript
You might like
调频问题解答
2021/03/01 无线电
NT IIS下用ODBC连接数据库
2006/10/09 PHP
PHP 数组基础知识小结
2010/08/20 PHP
php实现删除空目录的方法
2015/03/16 PHP
微信公众平台DEMO(PHP)
2016/05/04 PHP
PHP接收App端发送文件流的方法
2016/09/23 PHP
PHP时间函数使用详解
2019/03/21 PHP
Prototype Hash对象 学习
2009/07/19 Javascript
Jquery实战_读书笔记2 选择器
2010/01/22 Javascript
JavaScript 学习笔记(十五)
2010/01/28 Javascript
AJAX使用了UpdatePanel后无法使用alert弹出脚本
2010/04/02 Javascript
ExtJS实现文件下载的方法实例
2013/11/09 Javascript
javascript实例分享---具有立体效果的图片特效
2014/06/08 Javascript
js计算任意值之间随机数的方法
2015/01/16 Javascript
AngularJs bootstrap详解及示例代码
2016/09/01 Javascript
JS传参及动态修改页面布局
2017/04/13 Javascript
cocos2dx+lua实现橡皮擦功能
2018/12/20 Javascript
js找出5个数中最大的一个数和倒数第二大的数实现方法示例小结
2020/03/04 Javascript
python 构造三维全零数组的方法
2018/11/12 Python
python将list转为matrix的方法
2018/12/12 Python
python 使用poster模块进行http方式的文件传输到服务器的方法
2019/01/15 Python
python 利用pandas将arff文件转csv文件的方法
2019/02/12 Python
详解Python的数据库操作(pymysql)
2019/04/04 Python
Python求离散序列导数的示例
2019/07/10 Python
twilio python自动拨打电话,播放自定义mp3音频的方法
2019/08/08 Python
python mysql 字段与关键字冲突的解决方式
2020/03/02 Python
把Anaconda中的环境导入到Pycharm里面的方法步骤
2020/10/30 Python
美国知名的旅游网站:OneTravel
2018/10/09 全球购物
PHP使用Redis队列执行定时任务实例讲解
2021/03/24 PHP
《美丽的公鸡》教学反思
2014/02/25 职场文书
2014年业务员工作总结范文
2014/11/17 职场文书
2015年护士工作总结范文
2015/03/31 职场文书
黄河绝恋观后感
2015/06/08 职场文书
演讲比赛通讯稿
2015/07/18 职场文书
《家》读后感:万惜拯救,冷暖自知
2019/09/25 职场文书
如何用python插入独创性声明
2021/03/31 Python