我基本上从http://getbootstrap.com/components/复制了Pills下拉菜单的组件,但它根本不起作用。单击菜单项时,下拉列表不会出现。我将我的确切代码复制到JSFiddle中:https://jsfiddle.net/j63f0o2f/。来自JSFiddle的片段:
<div class="nav">
<ul class="nav nav-pills nav-justified">
<li><a href="#">Robot Technology</a></li>
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Webdesign <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">HTML 5</a></li>
<li><a href="#">CSS 3</a></li>
<li><a href="#">Bootstrap 5</a></li>
</ul>
</li>
答案 0 :(得分:0)
你可能没有在<script src=""></script>
答案 1 :(得分:0)
您必须在<head>
标记内插入Bootstrap JavaScript文件和JQuery JavaScritp文件。仔细查看以下代码段:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
</head>
<body>
<h1>Hello, world!</h1>
<div class="nav">
<ul class="nav nav-pills nav-justified">
<li><a href="#">Robot Technology</a></li>
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Webdesign <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">HTML 5</a></li>
<li><a href="#">CSS 3</a></li>
<li><a href="#">Bootstrap 5</a></li>
</ul>
</li>
</ul>
</div>
</body>
</html>
&#13;