bootstrap属于前端展示框架,在HTML页面中使用的方法:
1,引入bootstrap的css样式库
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">2,引入jquery类库和bootstrap的js类库
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script><script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
通过 JavaScript 插件在导航条上创建下拉菜单<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Bootstrap dropdown with navbar example</title>
<link href="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<a class="brand" href="#">w3resource</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>
</body>
</html>
也可以在导航(标签和胶囊式标签)上应用 Dropdown(下拉菜单)JavaScript 插件。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Bootstrap dropdown with tabs and pills example</title>
<link href="/twitter-bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
</head>
<body>
<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>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)