Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

something wrong with the navbar

i have a problem with the navbar it works fine on full width but when i shrink the page the menu button appears and all but it is not working and i can’t seem to figure out where is the problem is located in my code

<nav id="mainNavbar" class="navbar navbar-dark bg-dark navbar-expand-md"> 
  <a href="#" class="navbar-brand">CANDY</a>
  <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navLinks">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div id="navLinks" class="collapse navbar-collapse">
    <ul class="navbar-nav">
     <li class="nav-item">
      <a href="#" class="nav-link">Home</a>
     </li>
     <li class="nav-item">
      <a href="#" class="nav-link">About</a>
     </li>
     <li class="nav-item">
      <a href="#" class="nav-link">Tickets</a>
     </li>
     
    </ul>
  </div>
</nav>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You’re mixing HTML Markup for Bootstrap 5 and importing Bootstrap 4.1.3.
One of the key differences is:

Bootstrap 5 (As per your code):
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navLinks">

Bootstrap 4:
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navLinks">

Two options:

  1. Change your HTML to the HTML markup for a navbar as per https://getbootstrap.com/docs/4.1/components/navbar/
  2. Change your bootstrap imports to Bootstrap 5 (preferred):
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading