导航栏下拉导致页面宽度扩展

时间:2017-11-01 16:55:18

标签: twitter-bootstrap bootstrap-4

Bootstrap 4 beta 2。

我有一个右对齐的导航栏,当我点击下拉列表时,页面向右延伸。我做错了什么

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

  <div class="collapse navbar-collapse justify-content-end ">
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" href="#">Alerts <i class="fa fa-bell"></i></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Messages <i class="fa fa-envelope"></i></a>
      </li>

      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Settings <i class="fa fa-cog"></i>
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
          <a class="dropdown-item" href="#">App Config</a>
        </div>
      </li>     

    </ul>
  </div>
</nav>

作为临时解决方案,我已在导航栏的第一个div上放置container课程。有什么方法比这更好吗?

1 个答案:

答案 0 :(得分:0)

根据Bootstrap关于菜单对齐的文档,将类.dropdown-menu-right添加到.dropdown-menu

https://getbootstrap.com/docs/4.0/components/dropdowns/#menu-alignment