移动设备上的Bootstrap导航栏无法正常工作

时间:2017-10-01 18:21:12

标签: html bootstrap-4

我正在学校(巴西)为我的俱乐部制作一个网站,我想知道如何在我的网站上解决这个问题。按下移动设备中的三条线不会做任何事情。

<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">

<title>ClubeDiversidade</title>
</head>
<style>
body {
background-color: orange;
}

</style>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Clube da diversidade</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarNavDropdown">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="#">Pagina inicial <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Inscrição</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="sobrenatural.html">Sobrenatural</a>
      </li>
<li class="nav-item">
        <a class="nav-link" href="#">Tecnologia</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Outras atividades</a>
      </li>
    </ul>
  </div>
</nav>
<div class="container-fluid">
  <center>Bem-vindo!!</center>
</div>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

嗨指的是Bootstrap Documentation

  

我们的许多组件都需要使用JavaScript才能运行。具体来说,它们需要jQuery,Popper.js和我们自己的JavaScript插件。将以下内容放在页面末尾附近,就在结束前&lt; / body&gt;标记,以启用它们。 jQuery必须先来,然后是Popper.js,然后是我们的JavaScript插件。

您需要将这些行添加到页面中才能正常工作。

<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>

我使用Bootstrap 4 Editor并复制了你的代码并且它完美地工作,因为编辑器内置了bootstrap javascripts。

答案 1 :(得分:0)

您需要在关闭正文之前添加 jquery bootstrap js才能进行切换。

注意:这里的顺序非常重要,首先放置jquery js链接然后再引导js。

&#13;
&#13;
<html>

<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">

  <title>ClubeDiversidade</title>
</head>
<style>
  body {
    background-color: orange;
  }
</style>

<body>
  <nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="#">Clube da diversidade</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
    <div class="collapse navbar-collapse" id="navbarNavDropdown">
      <ul class="navbar-nav">
        <li class="nav-item active">
          <a class="nav-link" href="#">Pagina inicial <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Inscrição</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="sobrenatural.html">Sobrenatural</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Tecnologia</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Outras atividades</a>
        </li>
      </ul>
    </div>
  </nav>
  <div class="container-fluid">
    <center>Bem-vindo!!</center>
  </div>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
</body>

</html>
&#13;
&#13;
&#13;