您好我想在Bootstrap 4中禁用导航栏折叠。如果导航栏占据整个宽度但在导航栏内容器类只允许默认宽度放置内容,那将会很好。
我已经尝试了这个Disable responsive navbar in bootstrap 4,但是没有使用其中的容器。
但那不起作用。
<nav class="navbar navbar-light bg-faded justify-content-between flex-nowrap flex-row">
<div class="container">
<a href="/" class="navbar-brand">PIM</a>
<ul class="nav navbar-nav flex-row">
<li class="nav-item"><a class="nav-link pr-3" href="">Login</a></li>
<li class="nav-item"><a class="nav-link" href="">Sign up</a></li>
</ul>
</div>
</nav>
看起来像:
如果Login对齐并且Sign Up将在导航栏中右对齐,那也很好。
答案 0 :(得分:21)
只需使用navbar-toggleable-xl
..
修改 - Bootstrap 4 beta现在为navbar-expand
<nav class="navbar navbar-toggleable-xl navbar-inverse bg-primary">
<div class="container">
<a class="navbar-brand" href="#">Navbar</a>
<div class="navbar-collapse collapse">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
</div>
</nav>
http://www.codeply.com/go/8FF7HX22L3
或者,可以使用flexbox实用程序类完成...
<nav class="navbar navbar-light bg-faded justify-content-between flex-nowrap flex-row">
<div class="container">
<a href="/" class="navbar-brand float-left">PIM</a>
<ul class="nav navbar-nav flex-row float-right">
<li class="nav-item"><a class="nav-link pr-3" href="">Login</a></li>
<li class="nav-item"><a class="nav-link" href="">Sign up</a></li>
</ul>
</div>
</nav>
答案 1 :(得分:15)
对于bootstrap 4 beta版
只需将navbar-expand
添加到<nav>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<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="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
&#13;