Reputation: 55
For some reason, my dropdown in my navigation bar is not working; nothing happens when it is clicked. I also find it strange because I copied this code from somewhere else, and it isn't working. I have checked for typos multiple times but came up with nothing.
My HTML:
<!DOCTYPE html>
<html>
<head>
<title>Website Template</title>
<!-- links to the css page and bootstrap -->
<link rel="stylesheet" type="text/css" href="main.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>
<!-- BEGIN NAVBAR -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header pull-left">
<a class="navbar-brand" href="#">Project Name</a>
</div>
<div class="navbar-header pull-right">
<ul class="nav navbar-nav pull-left">
<li><a class="" href="#">Text</a></li>
</ul>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#">Text</a></li>
<li><a href="#">Text</a></li>
<li><a href="#">Text</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a> <ul class="dropdown-menu">
<li><a href="#">Text</a></li>
<li class="divider"></li>
<li class="dropdown-header">Text</li>
<li><a href="#">Text</a></li>
<li><a href="#">Text</a></li>
</ul>
</li>
</ul>
<div class="navbar-right">
<ul class="nav navbar-nav">
<li><a href="#">Text</a></li>
<li><a href="#">Text</a></li>
</ul>
</div>
</div>
</div>
</div>
<!-- END NAVBAR -->
<div class="jumbotron">
<div class="container">
<h1>Text</h1>
<p>Paragraph.</p>
</div>
</div>
</body>
</html>
My CSS:
.jumbotron {
text-align: center;
}
body {
padding-top: 50px;
padding-bottom: 20px;
}
Upvotes: 1
Views: 80
Reputation: 391
You're not referencing the jQuery library and Bootstrap.js library in your <head>
tag..
The navbar requires a javascript library (collapse.js), all you need is here, check the text in the big red box.
EDIT: Put this CDN tag in your <head>
, make sure to put the latest jQuery library before this line.
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
Upvotes: 1