我似乎无法弄清楚。引导javascript之前引用jQuery,html代码也很好。有什么想法吗?
导航:
<nav class="navbar navbar-expand-lg navbar-light bg-white" style="border-bottom: 2px solid #ccc;">
<div class="container">
<a class="navbar-brand" href="<?php echo $url; ?>">
<img src="<?php $BASEURL;?>assets/img/logo.png" alt="CraftZealous"/>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link text-info" href="<?php echo $BASEURL; ?>" style="font-weight: 700;">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" href="<?php echo $BASEURL;?>faq">HELP & FAQ</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" href="<?php echo $BASEURL;?>community">COMMUNITY</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" href="#">NEWS</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto">
<?php if ($session->isAdmin()) { echo '<li class="nav-item"><a class="nav-link text-warning" href="admin/admin.php">ADMINCP</a></li>';} ?>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle text-danger" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="text-transform:uppercase;">SC</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="#">Profile</a>
<a class="dropdown-item" href="#">Account settings</a>
<a class="dropdown-item" href="process.php">Log out »</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
位于文件底部的javascript参考:
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
答案 0 :(得分:-1)
您的代码段是一个PHP脚本;您应该调试生成的HTML,而不是包含PHP的代码。
在删除PHP部分并在页面HEAD部分中包含Bootstrap 4 CSS文件之后:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
您的页面完全可以正常工作。
最终使用的HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-white" style="border-bottom: 2px solid #ccc;">
<div class="container">
<a class="navbar-brand" href="#">
<img src="assets/img/logo.png" alt="CraftZealous"/>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link text-info" href="#" style="font-weight: 700;">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" href="#faq">HELP & FAQ</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" href="#community">COMMUNITY</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" href="#">NEWS</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto">
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle text-danger" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="text-transform:uppercase;">SC</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="#">Profile</a>
<a class="dropdown-item" href="#">Account settings</a>
<a class="dropdown-item" href="process.php">Log out »</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>