Bootstrap Dropdown(下拉菜单)
描述
通过 Dropdown(下拉菜单)JavaScript 插件,您可以在 Bootstrap 中任何物体上创建 Dropdown 下拉菜单。在导航条、导航(标签和胶囊式标签)中提供了创建下拉菜单的完整支持。
使用该插件时,什么是必需的
您必须引用 jquery.js 和 bootstrap-dropdown.js 文件。这两个文件都位于 twitter-bootstrap-v2/docs/assets/js 文件夹内。然后您可以通过 javascript 调用下拉菜单。下面的实例演示了如何做到这点。
实例
实例
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<a class="brand" href="#">runcodex</a>
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li class="dropdown" id="accountmenu">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Tutorials<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">PHP</a></li>
<li><a href="#">MySQL</a></li>
<li class="divider"></li>
<li><a href="#">JavaScript</a></li>
<li><a href="#">HTML5</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="container-fluid">
<h1>Dropdown Example下拉菜单实例</h1>
</div>
<script type="text/javascript" src="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
<script type="text/javascript" src="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-dropdown.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.dropdown-toggle').dropdown();
});
</script>
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<a class="brand" href="#">runcodex</a>
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li class="dropdown" id="accountmenu">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Tutorials<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">PHP</a></li>
<li><a href="#">MySQL</a></li>
<li class="divider"></li>
<li><a href="#">JavaScript</a></li>
<li><a href="#">HTML5</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="container-fluid">
<h1>Dropdown Example下拉菜单实例</h1>
</div>
<script type="text/javascript" src="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
<script type="text/javascript" src="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-dropdown.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.dropdown-toggle').dropdown();
});
</script>
在线查看实例
在上面的实例中,演示了如何创建通过 JavaScript 插件在导航条上创建下拉菜单。
您也可以在导航(标签和胶囊式标签)上应用 Dropdown(下拉菜单)JavaScript 插件。下面的实例演示了如何做到这点。
实例
实例
<ul class="nav nav-pills">
<li class="dropdown all-camera-dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Tutorials
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li data-filter-camera-type="all"><a data-toggle="tab" href="#">HTML5</a></li>
<li data-filter-camera-type="Alpha"><a data-toggle="tab" href="#">PHP</a></li>
<li data-filter-camera-type="Zed"><a data-toggle="tab" href="#">MySQL</a></li>
<li data-filter-camera-type="Bravo"><a data-toggle="tab" href="#">JavaScript</a></li>
</ul>
</li></ul>
<script type="text/javascript" src="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
<script type="text/javascript" src="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-dropdown.js"></script>
<li class="dropdown all-camera-dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Tutorials
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li data-filter-camera-type="all"><a data-toggle="tab" href="#">HTML5</a></li>
<li data-filter-camera-type="Alpha"><a data-toggle="tab" href="#">PHP</a></li>
<li data-filter-camera-type="Zed"><a data-toggle="tab" href="#">MySQL</a></li>
<li data-filter-camera-type="Bravo"><a data-toggle="tab" href="#">JavaScript</a></li>
</ul>
</li></ul>
<script type="text/javascript" src="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
<script type="text/javascript" src="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-dropdown.js"></script>
在线查看实例
点我分享笔记