1、编写一个标准的下拉菜单,要求对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="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.css"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script> <script src="http://apps.bdimg.com/libs/bootstrap/3.2.0/js/bootstrap.js"></script> <title>Document</title> </head> <body> <div class="dropdown" style="margin-top: 200px"> <button type="button" class="btn btn-default" data-toggle="dropdown"> 前端开发 <span class="caret"></span> </button> <ul class="dropdown-menu"> <li class="dropdown-header">圣贤教育</li> <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> </ul> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
2、使用按钮组编写一个分裂式下拉菜单
实例
<!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="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.css"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script> <script src="http://apps.bdimg.com/libs/bootstrap/3.2.0/js/bootstrap.js"></script> <title>Document</title> </head> <body> <div class="btn-group"> <button type="button" class="btn btn-success">感恩的心</button> <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="caret"></span> <span class="sr-only">Toggle Dropdown</span> </button> <ul class="dropdown-menu"> <li><a href="#">布施</a></li> <li><a href="#">爱语</a></li> <li><a href="#">利行</a></li> <li role="separator" class="divider"></li> <li><a href="#">同事</a></li> </ul> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例