简体   繁体   English

我的切换器不工作。 我试过将 js cdn 放在顶部和底部,但没有用

[英]My toggler is not working. I have tried placing js cdn in top and bottom both but didn't work

I tried placing the js cdn in top and it did not work.我尝试将 js cdn 放在顶部,但它没有用。 I was trying to make my navbar responsive and used toggler.我试图让我的导航栏响应并使用切换器。 The navbar became responsive but the toggler button is not working.导航栏变得有响应,但切换器按钮不起作用。

在此处输入图像描述

Here is my code, the hamburger menu is not working:这是我的代码,汉堡菜单不起作用:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>TinDog</title>
  <!-- Latest compiled and minified CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">

  <!-- Latest compiled JavaScript -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="css/styles.css">
</head>

<body>
  <section id="title">
    <!-- Nav Bar -->
    <nav class="navbar bg-dark navbar-expand-lg navbar-dark">
      <a class="navbar-brand" href="">Tindog</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="NssavbarSupportedContent" 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 ms-auto">
          <li class="nav-item">
            <a class="nav-link" href="">Contact</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="">Pricing</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="">Download</a>
          </li>
        </ul>
      </div>
    </nav>
   </section>
 </body>
</html>

For Bootstrap V5 it's data-bs-toggle not data-toggle , plus you needed a "#" to point the target to an ID not a class.对于 Bootstrap V5,它是data-bs-toggle而不是data-toggle ,而且您需要一个“#”来将目标指向一个 ID 而不是一个类。 Lastly you had a typo "NssavbarSupportedContent" should be "navbarSupportedContent".最后你有一个错字“NssavbarSupportedContent”应该是“navbarSupportedContent”。

 <:DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>TinDog</title> <.-- Latest compiled and minified CSS --> <link href="https.//cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap:min.css" rel="stylesheet"> <.-- Latest compiled JavaScript --> <script src="https.//cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> <link rel="stylesheet" href="css/styles.css"> </head> <body> <section id="title"> <!-- Nav Bar --> <nav class="navbar bg-dark navbar-expand-lg navbar-dark"> <a class="navbar-brand" href="">Tindog</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 ms-auto"> <li class="nav-item"> <a class="nav-link" href="">Contact</a> </li> <li class="nav-item"> <a class="nav-link" href="">Pricing</a> </li> <li class="nav-item"> <a class="nav-link" href="">Download</a> </li> </ul> </div> </nav> </section> </body> </html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CSS React JS 中的模块无法正常工作,我几乎尝试了所有方法,但没有解决 - CSS Modules in React JS not working, i have tried literally everything but it didn't solved 我已经尝试过,但是我的程序似乎不起作用 - I have tried but my program doesn't seem to work javascript if else 语句不起作用。 即使我单击 twoStory 图像,它也会返回 singleStory。 我试过了!=和--- - javascript if else statement not working. It returns singleStory even if I click on the twoStory image. I have tried != and --- 是否可以更改 swiper 滑块中的方向垂直滑块? 我想要从上到下和从下到上的选项? - Is it possible to change the direction vertical slider in swiper slider? I want to have both top to bottom and bottom to top option? $ {document).ready不能替换在页面底部声明的js,但是我需要在脚本顶部 - $(document).ready can't replace js declared at bottom of the page, but I need to have the script at the top 我试图拖放一个元素。 为什么我的代码不能正常工作? - I have tried to drag and drop an element. Why won't my code work properly? 我似乎无法让我的悬停效果在按钮上工作。 尝试了很多技巧 - i can't seem to get my hover effects to work on button. have tried many tips 为什么我的编辑页面在 Laravel 中不起作用? 我用过 vue.js - Why my edit page didn't work in Laravel? I used vue.js 我尝试使用 fisher-yates shuffle 字符串,但没有奏效 - I tried using a fisher-yates shuffle for strings, but it didn't work 我的 headerStyle 不起作用。 我试图分配背景颜色,但在我运行它时它没有出现 - My headerStyle doesn't work. I have tried to assign a background color though it doesn't appear when I run it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM