Bootstrap切换器无法正常工作。该图标是可见的,但在减小浏览器大小后,它不会丢弃链接。我也阅读了其他解决方案,但主要是说在引导之前加载javascript,我尝试在引导程序之前首先加载js,但它仍然没有工作。以下是我正在使用的代码
<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="Bootstrap/js/bootstrap.min.js"type="text/javascript"></script>
<link href="Bootstrap/css/bootstrap.min.css" rel ="stylesheet">
<script src ="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html;">
<title>HTML Test</title>
</head>
<body >
<!-- Container -->
<div class=”container”>
<!-- Navigation -->
<nav class="navbar sticky-top navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Navigation Bar</a>
<button class ="navbar-toggler" type ="button" data-toggler="collapse" data-target="#navbarSupportContent" aria-expanded="flase" aria-lable ="Toggle navigation">
<span class = "navbar-toggler-icon" ></span>
</button>
<!-- links -->
<div class="collapse navbar-collapse" id="navbarSupportContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<!-- Drop down -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href ="#" data-toggle ="dropdown">More</a>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
<a class="dropdown-item" href="#">Link 3</a>
<a class="dropdown-item" href="#">Link 4</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Logout</a>
</li>
</ul>
</div>
<!-- Search Button and text column -->
<form class="form-inline my-2 my-lg-0" >
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-lable="Search">
<button class="btn btn-outline-sucess my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
<!-- pagination -->
<nav aria-lable="pageNavigation" >
<ul class="pagination justify-content-end">
<li class="pagination-item"><a Class="page-link" href="#">Previous</a></li>
<li class="pagination-item"><a Class="page-link" href="#">1</a></li>
<li class="pagination-item"><a Class="page-link" href="#">2</a></li>
<li class="pagination-item"><a Class="page-link" href="#">3</a></li>
<li class="pagination-item"><a Class="page-link" href="#">Next</a></li>
</ul>
</nav>
</div>
</body>
</html>
答案 0 :(得分:0)
切换按钮上有一个拼写错误。它应该是data-toggle="collapse"
而不是data-toggler="collapse"
。
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportContent" aria-expanded="flase" aria-lable="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>