按钮组允许多个按钮被堆叠在同一行上,实现起来非常简单。
0x01 基本用法
直接看下面的例子:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1"> <link href=""> <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src=""></script> <title>按钮组</title> </head> <body> <div> <div> <h3>水平排列</h3> <div> <button type="button">Left</button> <button type="button">Middle</button> <button type="button">Right</button> </div> </div> <div> <h3>垂直排列</h3> <div> <button type="button">Top</button> <button type="button">Middle</button> <button type="button">Bottom</button> </div> </div> <div> <h3>两端对齐</h3> <div> <a href="#">Left</a> <a href="#">Middle</a> <a href="#">Right</a> </div> </div> </div> </body> </html>
效果如下:
需要注意的是,两端对齐的样式只对a标签有效,对button无效。
0x02 嵌套下拉菜单
下面是一个按钮组嵌套下拉菜单的例子:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1"> <link href=""> <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src=""></script> <title>按钮嵌套下拉菜单</title> </head> <body> <div> <div> <h3>按钮嵌套下拉菜单</h3> </div> <div> <button type="button">按钮1</button> <button type="button">按钮2</button> <a href="#">超链接</a> <div> <div> <button type="button" data-toggle="dropdown"> 下拉菜单 <span></span> </button> <ul> <li><a href="#">菜单1</a></li> <li><a href="#">菜单2</a></li> <li></li> <li><a href="#">菜单3</a></li> <li><a href="#">菜单4</a></li> </ul> </div> </div> <button type="button">按钮3</button> </div> </div> </body> </html>
效果如下:
如果大家还想深入学习,可以点击这里进行学习,再为大家附3个精彩的专题: