skip to Main Content

I wrote the following navbar code using Bootstrap 4.
1. I cannot figure out why the 3-bar icon will not show on the right side 2. Why the onclick on the links will not fire properly. I have to click on the link and then anywhere else on the window for the link to become underlined.
3. I cannot align the menu item to the right

$('.nav-link').on('click', function () {
  $('.active').removeClass('active');
  $(this).addClass('active');
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="navbar navbar-toggleable-md">
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navigation-menu" aria-controls="navigation-menu" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="#">WELCOME</a>
  <div class="navbar-collapse collapse" id="navigation-menu">
    <div class="navbar-nav mr-auto">
      <a class="nav-item nav-link active" href="#section1">link1</a>
      <a class="nav-item nav-link" href="#section2">link2</a>
    </div>
  </div>
</nav>

2

Answers


  1. “Glyphicons” have been removed from Bootstap 4.

    Dropped the Glyphicons icon font. If you need icons, some options are:
    the upstream version of Glyphicons
    Octicons
    Font Awesome

    Via: https://v4-alpha.getbootstrap.com/migration/#components

    The fix is to manually include Glyphicons css file.

    Login or Signup to reply.
  2. You need to specify navbar-light or navbar-inverse for the toggler icon, and active links to appear..

    <nav class="navbar navbar-light navbar-toggleable-md">

    or

    <nav class="navbar navbar-inverse navbar-toggleable-md">

    http://www.codeply.com/go/HZBegMbGii

    Also, ml-auto would be used to push the navbar-nav to the right

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search