Responsive bootstrap navbar does not open

Asked

Viewed 219 times

-1

I’m trying to create a responsive menu but, when it’s in the small device view, the button appears but click does not open the links:

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
       <!-- Bootstrap CSS -->
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">

    <title>Português fácil</title>
</head>
<body>
    <nav class="navbar  navbar-expand-lg navbar-dark bg-dark">
        <a href="#" class="navbar-brand">Português fácil</a>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#menuPrincipal" aria-controls="menuPrincipal" aria-expanded="false" aria-label="Menu collapse">
            <span class="navbar-toggler-icon"></span>
        </button>


        <div id="menuPrincipal" class="collapse navbar-collapse">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a href="#" class="nav-link">Inicio</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">Contato</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">Sobre</a>
                </li>
            </ul>
        </div>
    </nav>

<!-- Scrips -->
<script type="text/javascript" href="js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" href="js/bootstrap.min.js"></script>
</body>
</html>
  • Here it worked normal. Take a test with these two libraries: <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"> and <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>

  • It did not work, when I lower the screen the button appears, but when clicking the links are not shown

  • I tested it here and it works right.

1 answer

0


Check if your JS files are correct

<script type="text/javascript" href="js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" href="js/bootstrap.min.js"></script>

In doubt perform the tests by calling the below

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
  • worked well with this library. Thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.