将Bootstrap 4.0.0 Alpha更新到较新版本时,导航栏不起作用

时间:2019-01-29 13:22:01

标签: javascript angular bootstrap-4 frontend

我有一个小项目试图学习一些Angular,几个月之后,当我没有时间去研究它时,我就找回了它。 首先,我想更新我的引导程序版本,但是导航栏出现一些问题。 我的导航栏:

<nav class="navbar fixed-top navbar-toggleable-md navbar-inverse bg-inverse">
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="#">Navbar</a>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item" *ngFor="let menuItem of menuItems" routerLinkActive="active">
        <a class="nav-item nav-link" [routerLink]="[menuItem.path]" routerLinkActive="active">{{menuItem.title}}</a>
      </li>
    </ul>
    <form class="form-inline my-2 my-lg-0">
      <a href="https://www.linkedin.com/"><i class="fa fa-linkedin-square socialIcons" aria-hidden="true"></i></a>
      <a href="https://www.xing.com"><i class="fa fa-xing-square socialIcons" aria-hidden="true"></i></a>
      <a href="https://stackexchange.com/"><i class="fa fa-stack-overflow socialIcons" aria-hidden="true"></i></a>
      <input class="form-control mr-sm-2" type="text" placeholder="Search">
      <button class="btn btn-outline-default my-2 my-sm-0" type="submit">Search</button>
    </form>
  </div>
</nav>

这是我当前的工作库:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>

我正在尝试更新此处提供的官方版本: https://getbootstrap.com/docs/4.1/getting-started/download/

当我更新库时,导航栏根本不起作用,它仅在右上角显示标题为“导航栏”的链接。 有什么想法吗?

谢谢!

2 个答案:

答案 0 :(得分:1)

只需将navbar-toggleable-md更改为navbar-expand-md,并添加颜色,将navbar-inverse bg-inverse更改为navbar-dark bg-dark

您的汉堡菜单为left side,您可以通过在按钮前添加anchor tag来更改右侧菜单

<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
   <span class="navbar-toggler-icon"></span>
</button>

工作摘要

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

<nav class="navbar fixed-top navbar-expand-md navbar-dark bg-dark">
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="#">Navbar</a>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item" *ngFor="let menuItem of menuItems" routerLinkActive="active">
        <a class="nav-item nav-link" [routerLink]="[menuItem.path]" routerLinkActive="active">{{menuItem.title}}</a>
      </li>
    </ul>
    <form class="form-inline my-2 my-lg-0">
      <a href="https://www.linkedin.com/"><i class="fa fa-linkedin-square socialIcons" aria-hidden="true"></i></a>
      <a href="https://www.xing.com"><i class="fa fa-xing-square socialIcons" aria-hidden="true"></i></a>
      <a href="https://stackexchange.com/"><i class="fa fa-stack-overflow socialIcons" aria-hidden="true"></i></a>
      <input class="form-control mr-sm-2" type="text" placeholder="Search">
      <button class="btn btn-outline-default my-2 my-sm-0" type="submit">Search</button>
    </form>
  </div>
</nav>

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>

答案 1 :(得分:1)

是的,我很确定您应该首先阅读本文档。

Bootstrap 4, bg-inverse not showing?