Bootstrap崩溃正在崩溃,但是立即关闭崩溃

时间:2019-08-25 09:47:28

标签: javascript jquery html bootstrap-4

当我单击切换按钮时,折叠会下降,但是当结束向下动画时,折叠会上升而没有任何交互作用。

我尝试了所有库引用及其顺序定位,但是即使如此,我仍然获得与以前相同的结果。

这是我的HTML代码:

<nav class="navbar navbar-expand-lg navbar-dark bg-dark sti-navbar-light mb-xl-5 justify-content-center" id="mainNav">
    <div class="container align-content-center justify-content-center">
        <a class="navbar-brand" href="./link.php">NAME</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle"
                aria-controls="navbarToggle" aria-expanded="true" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarToggle">
            <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
                <li class="nav-item active">
                    <a href="./link.php" class="nav-link">LINK</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

我的导入在页面末尾(也在标题处尝试过):


<script src="./js/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.7/js/tether.min.js"></script>
<script src="./libs/bootstrap-4.3.1-dist/js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script>
<script src="./js/canvasjs.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>

我也尝试了bootstrap文档的链接,但是没有一个起作用。

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

那么可能是个问题吗? -导致订单和链接正常运行

1 个答案:

答案 0 :(得分:0)

BootStrapjQuery之类的外部库的实现需要一定的顺序,以便它们可以彼此正常工作。如果您随机添加库,而HTML对象找不到这些库,则可能会看到奇怪的设计问题或javascript代码无法正常工作。

请注意下面的代码片段如何添加外部库以及切换菜单如何成功工作。

我还建议使用完整的jQuery而不是苗条的版本。

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>

  
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark sti-navbar-light mb-xl-5 justify-content-center" id="mainNav">
    <div class="container align-content-center justify-content-center">
        <a class="navbar-brand" href="./link.php">NAME</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle"
                aria-controls="navbarToggle" aria-expanded="true" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarToggle">
            <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
                <li class="nav-item active">
                    <a href="./link.php" class="nav-link">LINK</a>
                </li>
            </ul>
        </div>
    </div>
</nav>