HTML Bootstrap下拉菜单不下拉

时间:2017-12-13 03:42:36

标签: jquery css html5 twitter-bootstrap

所以我正在学习如何使用Flask(一个python模块来帮助开发HTML页面),我还包括bootstrap来创建我的导航栏,但由于某种原因,导航的下拉菜单不会下拉

这是实际的下拉菜单代码:

<!-- Navigation Bar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="/">Navigation</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">
            <!-- Dropdown menu -->
            <li class="nav-item dropdown">

                <!-- Menu Title -->
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Animals
                </a>

                <!-- Dropdown -->
                <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">

                    <!-- Dinosaur Link -->
                    <a class="dropdown-item" href="/dinosaur_homepage">Dinosaurs</a>

                    <!-- Link Divider -->
                    <div class="dropdown-divider"></div>

                    <!-- Birds Link -->
                    <a class="dropdown-item" href="/birds_homepage">Birds</a>
                </div>

            </li>
        </ul>
    </div>
</nav>

这是整个源代码(不包括python文件):https://pastebin.com/VhrxkbYi

1 个答案:

答案 0 :(得分:0)

在你的情况下你错过了js和css文件

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>

<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="/">Navigation</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">
            <!-- Dropdown menu -->
            <li class="nav-item dropdown">

                <!-- Menu Title -->
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Animals
                </a>

                <!-- Dropdown -->
                <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">

                    <!-- Dinosaur Link -->
                    <a class="dropdown-item" href="/dinosaur_homepage">Dinosaurs</a>

                    <!-- Link Divider -->
                    <div class="dropdown-divider"></div>

                    <!-- Birds Link -->
                    <a class="dropdown-item" href="/birds_homepage">Birds</a>
                </div>

            </li>         
        </ul>
    </div>
</nav>