简体   繁体   中英

Bootstrap 3 navbar doesn't work anymore

Well... yesterday it worked, tomorrow dont... it's true!

On console it gives this message:

Error: Bootstrap dropdown require Popper.js (https://popper.js.org)

The page is loaded but the navbar doesn't look liked it should do: the voices are aligned in vertical instead that in horizontal (so I have many columns).

I see bootstrap 4 is finally out... but I would prefere to not pass at the new version.

In my html I use:

<link href='http://getbootstrap.com/dist/css/bootstrap.min.css' rel='stylesheet'>
<link href='http://getbootstrap.com/assets/css/ie10-viewport-bug-workaround.css' rel='stylesheet'>]
<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script type='text/javascript' src='http://getbootstrap.com/dist/js/bootstrap.min.js'></script>

I changed the last one (it doesn't have indication of the version) to:

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

and the message of error on the console is gone but the nav stay vertical. As alternative i tried to add:

script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>

and happen the same thing: the error message is gone but the navbar doesn't work. So, I didn't add this row.

Here my code for the nav in base.html :

<body id='body' style='margin:0; padding:10; height:100%; width:100%;'>
  <div id='wrapper' style='min-height:100%; position:relative;'>
    <nav class='navbar navbar-inverse navbar-fixed-top'>
      {% include '_navbar.html' %}
    </nav>
    [...]
  </div>
</body>

and _navbar.html :

{% load staticfiles %}
{% load i18n %}
<div class='container-fluid'>
  <div class='navbar-header'>
    <button type='button' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#navbar' aria-expanded='false' aria-controls='navbar'>
      <span class='sr-only'>Toggle navigation</span>
      <span class='icon-bar'></span>
      <span class='icon-bar'></span>
      <span class='icon-bar'></span>
    </button>
    <a class='navbar-brand' href="{% url 'core:homepage' %}">Title</a>
  </div>

  <div id='navbar' class='navbar-collapse collapse'>
    <ul class='nav navbar-nav navbar-right'>
      <li><a href="{% url 'auth_password_change' %}">change data</a></li>
      <li><a href="{% url 'auth_logout' %}?next=/home/">Exit</a></li>
      [...]
    </ul>
  </div>
</div>

To be clear my nav bar look something like:

                                                                                  Title
                                                                                  change data
                                                                                  Exit

instead of:

Title                                                                      change data   Exit

Instead of the CDN that you are using in your <link> tag, use this link instead

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />

If you try to go to this link, http://getbootstrap.com/dist/css/bootstrap.min.css you will see that in the very beginning, it says: Bootstrap v4.0.0-beta . So, use the link I've provided you, instead of the one in your <head> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM