Bootstrap折叠切换器无法加载

时间:2017-06-10 18:23:02

标签: html css twitter-bootstrap

所以我看过几十篇有关此类问题的帖子,并且找不到答案。我的导航栏菜单在崩溃时切换问题。当浏览器宽度较小时,会显示菜单按钮,但单击菜单按钮不会执行任何操作。显然,我需要它来显示菜单列表。这是代码:



<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar navbar-inverse bg-inverse navbar-toggleable-sm bg-faded navbar-fixed-top">
		<div class="container">
		<button class="navbar-toggler navbar-toggler-right" 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>
  <a id="header-initials" class="navbar-brand" href="home">JT</a>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#home">home</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#skills">skills</a>
      </li>
			<li class="nav-item">
        <a class="nav-link" href="#about">about</a>
      </li>
			<li class="nav-item">
        <a class="nav-link" href="#work">work</a>
      </li>
			<li class="nav-item">
        <a class="nav-link" href="#contact">contact</a>
      </li>
    </ul>
  </div>
	</div>
	</nav>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:1)

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>放在<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

之后

我已经测试了上述变化。它会起作用。

答案 1 :(得分:0)

您是否已将bootstrap.min.js添加到您的代码中? 如果不 在jQuery之后添加此代码

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>

希望这会有所帮助

答案 2 :(得分:0)

在关闭onClick标记以及其他JavaScript文件之前,您需要致电bootstrap.js。这里的例子

</body>