重新启动电脑后,我的引导程序导航栏切换按钮停止工作。我试图解决它,但我找不到问题。这是我的代码:
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- custom external links -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<link rel="stylesheet" type="text/css" href="custom.css">
<script src="custom.js"></script>
<title>Ebere Orisi</title>
</head>
<body>
<div class=""><!--OVERALLBODY-->
<div class="navigation"><!--NAVIGATION HEAD-->
<nav class="navbar navbar-expand-md fixed-top navbar-dark bg-dark">
<div class="container">
<div class="row">
<div class="navi-left">
<div>
<a class="navbar-brand" href="https://blurpshell.github.io">Ebere Orisi</a>
</div>
</div>
</div>
<div class="socialLinks mx-auto">
<a href="https://www.linkedin.com/in/ebereorisi/" target="_blank"><i class="fab fa-linkedin-in fa-lg"></i></a> 
<a href="https://blurpshell.wordpress.com" target="_blank"><i class="fab fa-blogger-b fa-lg"></i></a> 
<a href="https://github.com/ebereorisi" target="_blank"><i class="fab fa-github fa-lg"></i></a> 
<a href="https://twitter.com/blurp_shell" target="_blank"><i class="fab fa-twitter fa-lg"></i></a> 
</div>
<div class="navi-right">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#itSec">IT SECURITY <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#webDev">SOFTWARE & WEB </a>
<a class="nav-item nav-link" href="#getInTouch">CONTACT</a>
</div>
</div>
</div>
</div>
</nav>
</div><!--NAVIGATION HEAD-->
&#13;
请问问题是什么。以下是实际网站:https://ebereorisi.github.io
答案 0 :(得分:1)
您需要在html中的某处包含bootstrap javascript
才能使其正常工作:
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
我将它添加到控制台(在您的网站上),如下所示:
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js';
document.head.appendChild(script);
并且有效。
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- custom external links -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<link rel="stylesheet" type="text/css" href="custom.css">
<script src="custom.js"></script>
<title>Ebere Orisi</title>
</head>
<body>
<div class=""><!--OVERALLBODY-->
<div class="navigation"><!--NAVIGATION HEAD-->
<nav class="navbar navbar-expand-md fixed-top navbar-dark bg-dark">
<div class="container">
<div class="row">
<div class="navi-left">
<div>
<a class="navbar-brand" href="https://blurpshell.github.io">Ebere Orisi</a>
</div>
</div>
</div>
<div class="socialLinks mx-auto">
<a href="https://www.linkedin.com/in/ebereorisi/" target="_blank"><i class="fab fa-linkedin-in fa-lg"></i></a> 
<a href="https://blurpshell.wordpress.com" target="_blank"><i class="fab fa-blogger-b fa-lg"></i></a> 
<a href="https://github.com/ebereorisi" target="_blank"><i class="fab fa-github fa-lg"></i></a> 
<a href="https://twitter.com/blurp_shell" target="_blank"><i class="fab fa-twitter fa-lg"></i></a> 
</div>
<div class="navi-right">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#itSec">IT SECURITY <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#webDev">SOFTWARE & WEB </a>
<a class="nav-item nav-link" href="#getInTouch">CONTACT</a>
</div>
</div>
</div>
</div>
</nav>
</div><!--NAVIGATION HEAD-->
答案 1 :(得分:1)
导航栏切换按钮依赖于bootstrap javascript工作,因此在您的html文档中,您需要将其包含在页面底部,不要忘记包含Jquery
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>