<!DOCTYPE html>
<html>
<head>
<title> Bootstrap navbar </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<script src="bootstrap.min.js"></script>
<script src="jquery-slim.min.js"></script>
<script src="popper.min.js"></script>
</body>
</html>
这是我的完整引导程序Navbar代码,当我们在移动设备上查看它时它会折叠,但是当我们选择按钮打开Navbar时,它没有打开。
答案 0 :(得分:1)
好的,问题是你的js文件的顺序。 Jquery文件需要首先才能使其他文件正常工作,因为它们使用的是jquery。
<script src="bootstrap.min.js"></script>
<script src="jquery-slim.min.js"></script>
<script src="popper.min.js"></script>
它现在可以使用了。
<script src="jquery-slim.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="popper.min.js"></script>