Upgrade to Bootstrap 4.1.x
Remove the navbar-expand*
class.
In the beta version, the navbar-toggleable-*
class was replaced with navbar-expand-*
, leading to a change in functionality. Since the navbar defaults to a collapsed/mobile state (xs), excluding the navbar-expand-*
class ensures that the menu remains collapsed on all tiers.
Beta demonstration:
Bootstrap 4.1.3:
Original Response (Bootstrap 4 alpha)
In Bootstrap 4, the navbar differs significantly from version 3.x as it is always collapsed by default unless one of the navbar-toggleable-* classes overrides this behavior. Ensure your navbar does not contain the navbar-toggleable-*
class.
<nav class="navbar navbar-fixed-top">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#collapsingNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="navbar-collapse collapse" id="collapsingNavbar">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Wow</a>
</li>
</ul>
</div>
</nav>
Alpha demonstration: