1

I need a help to make my li elements float to the right of navbar.

<nav class="navbar navbar-toggleable-md navbar-fixed-top topnav" role="navigation">
  <div class="navbar-header">
    <a class="navbar-brand" href="#" target="_blank" id="heading">Samrat Luitel</a>
  </div>
  <div>
    <ul class="navbar-nav navbar-right">
      <li class="nav-item"><a href="#home" style="color:black" class="nav-link">Home</a></li>
      <li class="nav-item"><a href="#home" style="color:black" class="nav-link">About Us</a></li>
      <li class="nav-item"><a href="#home" style="color:black" class="nav-link">Contact Us</a></li>
    </ul>
  </div>
</nav>
Dhaval Jardosh
  • 7,151
  • 5
  • 27
  • 69
Samrat Luitel
  • 369
  • 2
  • 8
  • 22

2 Answers2

1

How about using Grids in this scenario

You give grid of col-4 to you List Item and Grid col-8 to your Brand Name.

In that way you will be able to achieve what you are looking for.

And a little bit of CSS styling will make it better.


.navbar-right{
  float:right;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-toggleable-md navbar-fixed-top topnav col-12" role="navigation">
  <div class="navbar-header col-8">
    <a class="navbar-brand" href="#" target="_blank" id="heading">Samrat Luitel</a>
  </div>
  <div class="col-4">
    <ul class="nav navbar-nav navbar-right">
      <li class="nav-item"><a href="#home" style="color:black" class="nav-link">Home</a></li>
      <li class="nav-item"><a href="#home" style="color:black" class="nav-link">About Us</a></li>
      <li class="nav-item"><a href="#home" style="color:black" class="nav-link">Contact Us</a></li>
    </ul>
  </div>
</nav>
Dhaval Jardosh
  • 7,151
  • 5
  • 27
  • 69
-1

Where are your classes coming from? Easiest way to force them to float right would be to define it in an external style sheet or in the HTML document. To do it in HTML all you need to do is:

    <style>
    .navbar-nav>li {
        float: right;
    }
    </style>
  • I'll have a look, if you use inspect element and select the `li`'s then look on the right (on chrome) you can see where the styles are coming from. To test it on different areas at the top of the style column type `float: right` and see if it changes anything – Harry Jones Nov 14 '17 at 16:42
  • does tether absent causes error. I found that on console – Samrat Luitel Nov 14 '17 at 16:46