我正在使用引导导航栏,但它无法按我的要求工作。我想要一个菜单​​,品牌在左边,菜单项和表格在右边。但正如您在示例中看到的:“ https://jsfiddle.net/bnrgcupL/”,菜单项显示在品牌旁边。你知道如何解决这个问题吗?

的HTML:

<nav class="navbar navbar-expand-md navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a>
  <button class="navbar-toggler" 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>

  <div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
    <form class="form-inline my-2 my-lg-0">
      <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
    </form>
  </div>
</nav>

最佳答案

mr-auto声明中删除类<ul class="navbar-nav">
如果您愿意的话,添加pull-right类,但不是必需的。

关于css - 右边的引导导航栏不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46181120/

10-12 15:11