Bootstrap 4响应式Navbar将不提供下拉菜单

时间:2018-08-12 00:01:44

标签: css bootstrap-4 navbar

我正在尝试使bootstrap导航栏的下拉菜单正常工作,但我还无法使菜单真正下拉。太微弱了,我已经将它涂成黑色,才能显示在页面上,但是当我单击它时,它不会提供任何选项。 JSFiddle here.

我将以下代码用于导航栏本身。

<nav class="navbar navbar-expand-md topHeader">
    <a class="navbar-brand nameHeader">
        <h1 class="navbarHeader">David Mitchell Barnett</h1>
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-controls="collapsibleNavbar" aria-expanded="false" aria-label="Toggle navigation" style="background-color: black" >
            <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="collapsibleNavbar">
        <ul class="navbar-nav ml-auto">
            <li class="nav-item">
                <a class="nav-link" href="index.html">
                    <h3>About</h3>
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="portfolio.html">
                    <h3>Portfolio</h3>
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="contact.html">
                    <h3>Contact</h3>
                </a>
            </li>
        </ul>
    </div>
</nav>

1 个答案:

答案 0 :(得分:0)

我注意到的问题是,在共享的JSFiddle中,js脚本放置在错误的位置,必须首先链接jquery,然后再链接引导js。

您的代码:

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

只需像这样切换顺序:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>