dropdown bootstrap menu does not open!

Asked

Viewed 97 times

-2

Page with bootstrap

 <nav class="navbar navbar-expand-lg navbar-light" aria-haspopup="true" aria-expanded="false">
     <a class="navbar-brand" href="#">
         <img src="img/Pictures-icon.png" width="70px">
    </a>

    <div class="collapse navbar-collapse">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="#conheça-nos">conheça-nos</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#atendimento">atendimento</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">parceiros</a>
            </li>
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  Dropdown
                </a>
                <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                  <a class="dropdown-item" href="#">Ação</a>
                  <a class="dropdown-item" href="#">Outra ação</a>
                  <div class="dropdown-divider"></div>
                  <a class="dropdown-item" href="#">Algo mais aqui</a>
                </div>
              </li>
              <li class="nav-item">
                <a class="nav-link disabled" href="#">Desativado</a>
              </li>
        </ul>
    </div> 
 </nav>
  • Put the complete code! That way this difficult contribute

  • <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Page with bootstrap</title> <link rel="stylesheet" type="text/css" href="bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="css/style.css"> </head>

  • I commented here the rest of my code because in the edition the <head> n part was appearing

  • Some Bootstrap functions only work with jQuery, like Collapse, for example.

  • Then I have to download the right jquey?

1 answer

1

This is a simple example, but watch out for the libraries used.

<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Dropdowns</h2>                                         
  <div class="dropdown">
    <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown Example
    <span class="caret"></span></button>
    <ul class="dropdown-menu">
      <li><a href="#">HTML</a></li>
      <li><a href="#">CSS</a></li>
      <li><a href="#">JavaScript</a></li>
    </ul>
  </div>
</div>

</body>
</html>

  • I’m using js, only css/bootstrap

  • it is important to use!

  • I have to use jquery o js together, or one of the two already works?

  • yes, javascript is responsible for the movement. html is a structure, css the display and javascritp is the action

  • <src="bootstrap.min.js"></script>

  • so it already works?

  • if vc inserted bootstrap.min.js in the root folder of the sites yes. Look out for the places where vc inserted *.js

Show 2 more comments

Browser other questions tagged

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