### 按钮下拉菜单
向按钮添加下拉菜单,只需要简单地在在一个 .btn-group 中放置按钮和下拉菜单即可
~~~
<!doctype html>
<html lang="en">
<head>
<!--网站编码格式,UTF-8 国际编码,GBK或 gb2312 中文编码-->
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="Keywords" content="关键词一,关键词二">
<meta name="Description" content="网站描述内容">
<meta name="Author" content="Yvette Lau">
<meta name = "viewport" content = " width = device-width, initial-scale = 1 ">
<title>BootstrapDemo</title>
<!--css js 文件的引入-->
<link rel="stylesheet" type="text/css" href="../bootstrap-3.3.5-dist/css/bootstrap.min.css">
<script type="text/javascript" src = "../jquery-1.11.2.min.js"></script>
<script type="text/javascript" src = "../bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>
</head>
<body style="padding: 20px;">
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle = "dropdown">按钮菜单
<span class = "caret"></span>
</button>
<ul class="dropdown-menu" role = "menu">
<li role = "presentation"><a href="#">子菜单1</a></li>
<li role = "presentation"><a href="#">子菜单2</a></li>
<li role = "presentation"><a href="#">子菜单3</a></li>
<li role = "presentation"><a href="#">子菜单4</a></li>
</ul>
</div>
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-warning dropdown-toggle" data-toggle = "dropdown">按钮菜单
<span class = "caret"></span>
</button>
<ul class="dropdown-menu" role = "menu">
<li role = "presentation"><a href="#">子菜单1</a></li>
<li role = "presentation"><a href="#">子菜单2</a></li>
<li role = "presentation"><a href="#">子菜单3</a></li>
<li role = "presentation"><a href="#">子菜单4</a></li>
</ul>
</div>
</body>
</html>
~~~
此处我们未使用div class = "dropdown",尽管dropdown也可以实现按钮下拉菜单,但是dropdown是块级显示的。而.btn-group
的display是inline-block.
效果:
![](https://box.kancloud.cn/2016-04-07_570603f69e447.jpg)
### 分割的按钮下拉菜单
使用两个Button,一个显示内容,另一个用来显示下拉功能
~~~
<body style="padding: 20px;">
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-info">按钮菜单</button>
<button type="button" class="btn btn-info dropdown-toggle" data-toggle = "dropdown">
<span class = "caret"></span>
</button>
<ul class="dropdown-menu" role = "menu">
<li role = "presentation"><a href="#">子菜单1</a></li>
<li role = "presentation"><a href="#">子菜单2</a></li>
<li role = "presentation"><a href="#">子菜单3</a></li>
<li role = "presentation"><a href="#">子菜单4</a></li>
</ul>
</div>
<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-warning">按钮菜单</button>
<button type="button" class="btn btn-warning dropdown-toggle" data-toggle = "dropdown">
<span class = "caret"></span>
</button>
<ul class="dropdown-menu" role = "menu">
<li role = "presentation"><a href="#">子菜单1</a></li>
<li role = "presentation"><a href="#">子菜单2</a></li>
<li role = "presentation"><a href="#">子菜单3</a></li>
<li role = "presentation"><a href="#">子菜单4</a></li>
</ul>
</div>
</body>
~~~
效果:
![](https://box.kancloud.cn/2016-04-07_570603f6adf1b.jpg)
### 按钮上拉菜单
只需要在.btn-group容器中添加.dropup即可。
~~~
<body style="padding: 200px;">
<div class="btn-group btn-group-lg dropup">
<button type="button" class="btn btn-info">按钮菜单</button>
<button type="button" class="btn btn-info dropdown-toggle" data-toggle = "dropdown">
<span class = "caret"></span>
</button>
<ul class="dropdown-menu" role = "menu">
<li role = "presentation"><a href="#">子菜单1</a></li>
<li role = "presentation"><a href="#">子菜单2</a></li>
<li role = "presentation"><a href="#">子菜单3</a></li>
<li role = "presentation"><a href="#">子菜单4</a></li>
</ul>
</div>
<div class="btn-group btn-group-lg dropup">
<button type="button" class="btn btn-warning">按钮菜单</button>
<button type="button" class="btn btn-warning dropdown-toggle" data-toggle = "dropdown">
<span class = "caret"></span>
</button>
<ul class="dropdown-menu" role = "menu">
<li role = "presentation"><a href="#">子菜单1</a></li>
<li role = "presentation"><a href="#">子菜单2</a></li>
<li role = "presentation"><a href="#">子菜单3</a></li>
<li role = "presentation"><a href="#">子菜单4</a></li>
</ul>
</div>
</body>
~~~
![](https://box.kancloud.cn/2016-04-07_570603f6c0ae7.jpg)
- 前言
- jQuery轮播图插件
- JS模拟事件操作
- JS闭包与变量
- JS绑定事件
- HTML5之file控件
- JavaScript的this词法
- JavaScript的this词法(二)
- JS this词法(三)
- JS检测浏览器插件
- JS拖拽组件开发
- number输入框
- Modernizr.js和yepnode.js
- DOM变化后事件绑定失效
- div和img之间的缝隙问题
- 详解JavaScript作用域
- bootstrap入门
- 表单验证(登录/注册)
- Bootstrap网格系统
- Bootstrap排版
- Bootstrap创建表单(一)
- Bootstrap表单(二)
- Bootstrap按钮
- Bootstrap图片
- Bootstrap字体图标(glyphicons)
- Bootstrap的aria-label和aria-labelledby
- Bootstrap下拉菜单
- Bootstrap按钮组
- Bootstrap按钮菜单
- Bootstrap输入框组
- Bootstrap导航元素
- Bootstrap导航栏
- sublimeText频频崩溃
- JQuery不同版本的差异(checkbox)
- Bootstrap面包屑导航、分页、标签、徽章
- Bootstrap警告
- Bootstrap进度条
- 前端的上传下载
- JS字符串的相关方法
- CSS3选择器(全)
- CSS3新增文本属性详述
- 利用CSS3实现图片切换特效
- CSS3新增颜色属性
- CSS3的border-radius属性详解
- JS创建对象几种不同方法详解
- JS实现继承的几种方式详述(推荐)
- CSS3响应式布局
- JS模块化开发(requireJS)
- 利用@font-face实现个性化字体
- 前端在html页面之间传递参数的方法
- CSS自动换行、强制不换行、强制断行、超出显示省略号
- 如何在Html中引入外部页面
- reactJS入门
- React组件生命周期
- 使用React实现类似快递单号查询效果
- ReactJS组件生命周期详述
- React 属性和状态详解