我已经构建了一个Navbar,它完全是如何在教程上完成的,但是当它应该水平显示时,我的导航栏会以某种方式垂直显示.关于如何解决这个问题的任何想法?提前致谢
<nav class="navbar navbar-fixed-top navbar-light bg-faded"> <div class='container'> <ul class="nav navbar-nav"> <li class='nav-item'> <a class='nav-link' routerLink="/home" routerLinkActive="active">Home</a> </li> <li class='nav-item'> <a class='nav-link' routerLink="/documents" routerLinkActive="active">Docs</a> </li> <li class="nav-item dropdown"> <div ngbDropdown class="d-inline-block dropdown-links"> <button class="btn btn-outline-primary" id="proposalDropdown" ngbDropdownToggle> Proposals </button> <div class="dropdown-menu" aria-labelledby="proposalDropdown"> <a class="dropdown-item" routerLink="/proposals" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true}">Proposals</a> <a class="dropdown-item" routerLink="/proposals/new" routerLinkActive="active">New Proposal</a> </div> </div> </li> </ul> </div> </nav>
解决方法
将navbar-toggleable-sm(md / lg)添加到nav元素,使其水平直到sm,否则每次都渲染为垂直.
<nav class="navbar navbar-toggleable-sm navbar-fixed-top navbar-light bg-faded"> .... </nav>