bootstrap 3导航栏折叠按钮不工作

7vhp5slm  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(201)

this is the image with probelem我是一名学生,我在引导程序的问题。我有一个问题,以创造一个崩溃的引导程序,我会尝试一切,但它仍然不工作,请帮助。
这里是我的代码:

<!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>Anything</title>
  <meta name="description" content="">
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

  <!-- Optional theme -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

  <!-- Latest compiled and minified JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  <script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
 </head>

 <style>
  body {
  padding-top: 51px;
}
@media (max-width: 979px) {
  body {
    padding-top: 0px;
	font-family: 'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  }
}
 </style>
 
 <body>
  
  <!-- NavBar -->
   
   <nav class="navbar navbar-inverse navbar-fixed-top" id="my-navbar">
    <div class="container">
	 <div class="navbar-header">
	  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#nav-collapse">
	   <span class="icon-bar"></span>
	   <span class="icon-bar"></span>
	   <span class="icon-bar"></span>
	   <span class="icon-bar"></span>
	  </button>
	  
	  <a href="#" class="navbar-brand">Anything</a>
	 </div>
	 <div class="collapse navbar-collapse" id="nav-collapse">
	   <ul class="nav navbar-nav"> 
	    <li><a href="#">HOME</a></li>
		<li><a href="#">COURCES</a></li>
		<li><a href="#">THEMES</a></li>
		<li><a href="#">EXTRA</a></li>
	   </ul>
	 </div>
	</div>
   </nav>
 </body>
</html>
p8ekf7hl

p8ekf7hl1#

您需要在Bootstrap之前加载JQuery库,因为JQuery是Bootstrap javascript文件的依赖项。要解决此问题,只需交换以下两行代码:

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>

顺便说一句:所有的Bootstrap Javascript插件都需要JQuery。navbar css功能使用Bootstrap中的collapse Javascript插件,因此需要JQuery。

相关问题