如何使用Bootstrap CSS组件之下拉菜单?
Bootstrap下拉菜单,常用在开发项目中,今天为大家介绍介绍
dropdown、dropdown-menu、dropdown-header、divider、dropdown-submenu
例子见下拉菜单.html
//源码 .dropup, .dropdown { position: relative; } .dropdown-toggle:focus { outline: 0; } .dropdown-menu { position: absolute; top: 100%; left: 0; z-index: 1000; display: none; float: left; min-width: 160px; padding: 5px 0; margin: 2px 0 0; font-size: 14px; text-align: left; list-style: none; background-color: #fff; -webkit-background-clip: padding-box; background-clip: padding-box; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, .15); border-radius: 4px; -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175); box-shadow: 0 6px 12px rgba(0, 0, 0, .175); } .dropdown-menu.pull-right { right: 0; left: auto; } .dropdown-menu .divider { height: 1px; margin: 9px 0; overflow: hidden; background-color: #e5e5e5; } .dropdown-header { display: block; padding: 3px 20px; font-size: 12px; line-height: 1.42857143; color: #777; white-space: nowrap; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Bootstrap从3.0版本开始全面支持移动平台,贯彻移动先行宗旨 --> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <!-- --> <div class="btn-group"> <button type="button" class="btn btn-default 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> </ul> </div> <!-- dropdown/dropdown-menu/dropdown-header --> <div class="dropdown"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> 我的书籍<span class="caret"></span> </button> <ul class="dropdown-menu"> <li class="dropdown-header">前端</a></li> <li><a href="#">JS</a></li> <li><a href="#">HTML</a></li> <li><a href="#">CSS</a></li> <li class="divider"></li> <li class="dropdown-header">后台</li> <li><a href="#">PYTHON</a></li> <li><a href="#">JAVA</a></li> </ul> </div> <!-- bootstrap是基于jQuery--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script> </body> </html>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持路饭。
本文地址:http://www.45fan.com/bcdm/86198.html