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

Why does my Navbar content in Bootstrap not show up when I click the hamburger menu?

Quick question. When I click the hamburger button in bootstrap, the content doesn’t slide down. I was following a tutorial on it, and couldn’t tell what I was missing on this. Am I missing something in the button tag? Everything else is working fine. Any ideas?
Thanks!

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Schenck Guitars</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link href="css/style.css" rel="stylesheet" type="text/css"/>
</head>
  <body>
    <div class="nav-container">
      <nav class="navbar navbar-expand-md navbar-light">
        <a href="#" class="navbar-brand">Bootstrap 5</a>
        <button
         class="navbar-toggler"
         type="button"
         data-bs-toggle="collapse"
         data-bs-target="#toggleMobileMenu"
         aria-controls="toggleMobileMenu"
         aria-expanded="false"
         aria-label="Toggle navigation"
        >
        <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="toggleMobileMenu">
          <ul class="navbar-nav">
            <li>
              <a class="nav-link" href="#">Pricing</a>
            </li>
            <li>
              <a class="nav-link" href="#">Features</a>
            </li>
            <li>
              <a class="nav-link" href="#">Gallery</a>
            </li>
            <li>
              <a class="nav-link" href="#">Portfolio</a>
            </li>
            <li>
              <a class="nav-link" href="#">Resources</a>
            </li>
            <li>
              <a class="nav-link" href="#">Suppert</a>
            </li>
            <li>
              <a class="nav-link" href="#">Contact</a>
            </li>
          </ul>
        </div>
      </nav>
    </div>
  <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.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  <script src="js/scripts.js"></script>
</body>
</html>

>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 are mixing bootstrap 4 and 5. I changed this (which is syntax for BS 5):

data-bs-toggle="collapse"
data-bs-target="#toggleMobileMenu"

to this (which is syntax for BS 4):

data-toggle="collapse"
data-target="#toggleMobileMenu"

You can of course go the other direction and switch to BS 5 CDN.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Schenck Guitars</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link href="css/style.css" rel="stylesheet" type="text/css"/>
</head>
  <body>
    <div class="nav-container">
      <nav class="navbar navbar-expand-md navbar-light">
        <a href="#" class="navbar-brand">Bootstrap 5</a>
        <button
         class="navbar-toggler"
         type="button"
         data-toggle="collapse"
         data-target="#toggleMobileMenu"
         aria-controls="toggleMobileMenu"
         aria-expanded="false"
         aria-label="Toggle navigation"
        >
        <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="toggleMobileMenu">
          <ul class="navbar-nav">
            <li>
              <a class="nav-link" href="#">Pricing</a>
            </li>
            <li>
              <a class="nav-link" href="#">Features</a>
            </li>
            <li>
              <a class="nav-link" href="#">Gallery</a>
            </li>
            <li>
              <a class="nav-link" href="#">Portfolio</a>
            </li>
            <li>
              <a class="nav-link" href="#">Resources</a>
            </li>
            <li>
              <a class="nav-link" href="#">Suppert</a>
            </li>
            <li>
              <a class="nav-link" href="#">Contact</a>
            </li>
          </ul>
        </div>
      </nav>
    </div>
  <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.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  <script src="js/scripts.js"></script>
</body>
</html>
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