How do you hide and replace the navbar-toggler-icon in Bootstrap 4? Right now the code below just puts the 'X' below the hamburger menu.
<nav class="navbar navbar-toggleable-md">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false"
aria-label="Toggle navigation">
<span>X</span>
</button>
</nav>
The code you have now has 2 togglers, but I'm not sure why. You just need to replace the normal
navbar-toggler-icon
with an X..EDIT To toggle between the hamburger toggler icon and a close X, you'd need have both the X and hamburger icon inside the
navbar-toggler
. Add some CSS to handle thecollapsed
state of the navbar.http://www.codeply.com/go/fgHv33Q6UM
Update Bootstrap 4.2
The original question/answer is for Bootstrap 4 alpha. Once Bootstrap 4 was in beta, the
navbar-toggleable-*
classes changed tonavbar-expand-*
which effect the navbar breakpoint. Here is an updated example for Bootstrap 4.2...https://www.codeply.com/go/9AQ4AsYUph