编写一个标准的下拉菜单,要求对data-属性有较深的理解
实例
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="../../lib/bootstrap.css"> <script src="../../lib/jquery.js"></script> <script src="../../lib/bootstrap.js"></script> <title>标准的下拉菜单</title> </head> <body> <div class="container"> <div class="row"> <div class="col-md-8 col-md-offset-3"> <div class="dropdown"> <button type="button" class="btn btn-info" data-toggle="dropdown"> <span class="glyphicon glyphicon-menu-down" aria-hidden="true"></span> </button> <ul class="dropdown-menu"> <li><a href="">全部</a></li> <li><a href="">未读</a></li> <li><a href="">已读</a></li> <li class="divider"></li> <li><a href="">已回复</a></li> <li><a href="">已转发</a></li> <li><a href="">已星标</a></li> </ul>> </div> </div> </div> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
使用按钮组编写一个分裂式下拉菜单,了解这类常用控件编写的基本思路
实例
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="../../lib/bootstrap.css"> <script src="../../lib/jquery.js"></script> <script src="../../lib/bootstrap.js"></script> <title>分裂式下拉菜单</title> </head> <body> <div class="container"> <div class="row"> <div class="col-md-8 col-md-offset-3"> <div class="btn-group"> <button class="btn btn-info"> <span class="glyphicon glyphicon-menu-down"></span> </button> <button class="btn btn-info dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> </button> <ul class="dropdown-menu"> <li><a href="">全部</a></li> <li><a href="">未读</a></li> <li><a href="">已读</a></li> <li class="divider"></li> <li><a href="">已回复</a></li> <li><a href="">已转发</a></li> <li><a href="">已星标</a></li> </ul> </div> </div> </div> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
总结,按钮不困难