Navbar Bootstrap

1

I'm starting in web coding and need help on a problem, the menu I created is not correct, it was not formatted as indicated in the bootstrap documentation, it's listed.

Curso  
------------
Início
Perfil
Serviços
Depoimentos
Contatos

Follow the code:

<!doctype html>
<html lang="pt-br">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet"  href="node_modules/bootstrap/compiler/bootstrap.css">

    <link rel="stylesheet" href="node_modules/bootstrap/compiler/style.css">

    <title>Curso de bootstrap 4</title>
  </head>
  <body>

          <nav class="navbar navbar-expand-lg navbar-light bg-light">

              <div class="container">    
              <a class="navbar-brand h1 mb-0" href="#">Curso</a>


              <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSite">
                  <span class="navbar-toggler-icon"></span>
              </button>

                  <div class="collapse navbar-collapse" id="navbarSite">

                      <ul class="navbar-nav mr-auto">

                          <li class="nav-item">
                              <a class="nav-link" href="#">Início</a>
                          </li>
                           <li class="nav-item">
                              <a class="nav-link" href="#">Perfil</a>
                          </li>
                           <li class="nav-item">
                              <a class="nav-link" href="#">Serviços</a>
                          </li>
                           <li class="nav-item">
                              <a class="nav-link" href="#">Depoimentos</a>
                          </li>
                           <li class="nav-item">
                              <a class="nav-link" href="#">Contatos</a>
                          </li>
                      </ul>

                  </div>

            </div>
          </nav>


    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="node_modules/jquery/dist/jquery.js"></script>
    <script src="node_modules/popper/dist/umd/popper.js"></script>
    <script src="node_modules/bootstrap/dist/bootstrap.js"></script>
  </body>
</html>
    
asked by anonymous 17.12.2018 / 19:16

1 answer

3

Your problem is that you are using the Bootstrap 4 menu structure, but you are indexing Bootstrap 3 CSS and JS files. You have to pay attention to which version you are using and which documentation you are using.

If you want, here is the official NavBar Bootstrap 3 documentation link

Here's exactly what your code looks like, but with the indexed Bootstrap 4 files and it works perfectly!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<style>
    
</style>
</head>
<body>
    
        <nav class="navbar navbar-expand-lg navbar-light bg-light">

                <div class="container">    
                <a class="navbar-brand h1 mb-0" href="#">Curso</a>
  
  
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSite">
                    <span class="navbar-toggler-icon"></span>
                </button>
  
                    <div class="collapse navbar-collapse" id="navbarSite">
  
                        <ul class="navbar-nav mr-auto">
  
                            <li class="nav-item">
                                <a class="nav-link" href="#">Início</a>
                            </li>
                             <li class="nav-item">
                                <a class="nav-link" href="#">Perfil</a>
                            </li>
                             <li class="nav-item">
                                <a class="nav-link" href="#">Serviços</a>
                            </li>
                             <li class="nav-item">
                                <a class="nav-link" href="#">Depoimentos</a>
                            </li>
                             <li class="nav-item">
                                <a class="nav-link" href="#">Contatos</a>
                            </li>
                        </ul>
  
                    </div>
  
              </div>
            </nav>
    
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.bundle.min.js"></script>
</body>
</html>
    
17.12.2018 / 19:21