我正在练习使用Twitter Bootstrap。我一再尝试实施下拉菜单,但我似乎无法让它发挥作用。任何人都可以请帮助我确定为什么下面显示的HTML不会导致工作Bootstrap下拉菜单?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Home</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body>
<div class="container" style="padding: 20px;">
<div class="row">
<div class="col-lg-12" style="height: 50px; padding: 0px; margin: 0px;">
<ul class="nav nav-tabs">
<li class="active"><a href="#">Home</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Academic
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">academic 1</a></li>
<li><a href="#">academic 1</a></li>
<li><a href="#">academic 1</a></li>
</ul>
</li>
<li><a href="">Result</a></li>
<li><a href="">Notice Board</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-lg-2" style="height: 800px; border: 1px solid;">
</div>
<div class="col-lg-7" style="height: 800px; border: 1px solid;"></div>
<div class="col-lg-3" style="height: 800px; border: 1px solid;"></div>
</div>
<div class="row">
<div class="col-lg-12" style="height: 150px; border: 1px solid;">
</div>
</div>
</div>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
答案 0 :(得分:1)
你缺少jquery CDN
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
这可能是问题所在,除非它运作正常。
<html>
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container" style="padding: 20px;">
<div class="row">
<div class="col-lg-12" style="height: 50px; padding: 0px; margin: 0px;">
<ul class="nav nav-tabs">
<li class="active"><a href="#">Home</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Academic
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">academic 1</a></li>
<li><a href="#">academic 1</a></li>
<li><a href="#">academic 1</a></li>
</ul>
</li>
<li><a href="">Result</a></li>
<li><a href="">Notice Board</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-lg-2" style="height: 800px; border: 1px solid;">
</div>
<div class="col-lg-7" style="height: 800px; border: 1px solid;"></div>
<div class="col-lg-3" style="height: 800px; border: 1px solid;"></div>
</div>
<div class="row">
<div class="col-lg-12" style="height: 150px; border: 1px solid;">
</div>
</div>
</div>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
</b>
答案 1 :(得分:0)
你应该提及而不是
使用以下内容。希望它现在可以运作。
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown Example
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="#">HTML</a></li>
<li><a href="#">CSS</a></li>
<li><a href="#">JavaScript</a></li>
</ul>