Align bootstrap nav elements on the same line on collapse - html

This is my first attempt on creating a bootstrap menu, and I am stuck on the following issues. I tried different solutions suggested on similar questions, but with no success ☹
When collapsed I want the text: This is a Button to next to the button “button1”.
I’ve tried playing around with inline styling but I cannot get the 2 elements to stay on one line.
If I manage to display them on the same line, how do I make the text element to have the same left margin as the dropdown element below when collapsed?
I am not sure why the text & button element do not have the same left-margin as the dropdown below them.
Here is a copy of my code: https://jsfiddle.net/b512zesq/
thanks!
.navbar {
min-height: 80px;
background: #ee4035;
border-width: 0px;
border-radius: 0px;
color: blue;
}
.navbar a {
color: white!important;
}
.navbar-brand {
padding: 0 15px;
height: 80px;
line-height: 80px;
color: white;
}
.navbar-toggle {
/* (80px - button height 34px) / 2 = 23px */
margin-top: 23px;
padding: 9px 10px !important;
}
.navbar-btn {
/* (80px - button height 34px) / 2 = 23px */
margin-top: 18px;
margin-right: 30px;
padding: 9px 9;
background: #f37736;
border-width: 0px;
height: 35px;
width: 150px;
}
.navbar-text {
margin-top: 28px;
color: white;
}
.nav.navbar-nav.navbar-right li a {
color: white;
}
.dropdown-menu {
background: #ee4035;
}
.dropdown-menu>li>a:hover,
.dropdown-menu>li>a:focus {
background-color: #d6392f;
}
.navbar-default .navbar-nav>li>a:hover,
.navbar-default .navbar-nav>li>a:focus {
color: #ffffff;
}
.navbar-default .navbar-nav>li>.dropdown-menu {
background-color: #ee4035;
}
.navbar-default .navbar-nav>li>.dropdown-menu>li>a {
color: #ffffff;
}
.bar-nav>li>.dropdown-menu>li>a:hover,
.navbar-default .navbar-nav>li>.dropdown-menu>li>a:focus {
color: #ffffff;
background-color: #d6392f;
}
.navbar-default .navbar-nav>li>.dropdown-menu>li>.divider {
background-color: blue;
}
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:hover,
.navbar-default .navbar-nav>.active>a:focus {
color: #ffffff;
background-color: #d6392f;
}
.navbar-default .navbar-nav>.open>a,
.navbar-default .navbar-nav>.open>a:hover,
.navbar-default .navbar-nav>.open>a:focus {
color: #ffffff;
background-color: #d6392f;
}
.navbar-default .navbar-toggle {
border-color: #d6392f;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
background-color: #d6392f;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #ffffff;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
border-color: #ffffff;
}
.navbar-default .navbar-link {
color: #ffffff;
}
.navbar-default .navbar-link:hover {
color: #ffffff;
}
/*RESPONSIVE*************************************************/
#media (min-width: 768px) {
.navbar-nav>li>a {
/* (80px - line-height of 27px) / 2 = 26.5px */
padding-top: 26.5px;
padding-bottom: 26.5px;
line-height: 27px;
}
}
/**END OF RESPONSIVE********************************************/
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">logo</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li class="inline"><span class="navbar-text" style="color:white"><strong>this is a button</strong></span></li>
<li><a class="btn btn-danger navbar-btn" href="{$rlBase}/add-listing.html" role="button">button 1</a></li>
<form class="navbar-form navbar-left" style="padding:0px; border-top-width:0px;"></form>
<li class="dropdown">
<a class="dropdown-toggle" id="user-navbar" data-toggle="dropdown" href="{$rlBase}/login.html"><span class="glyphicon glyphicon-user"></span> USERNAME<span class="caret"></a>
</div>
</div>
</nav>

You could style your parent <ul> with display: inline-flex and put the list-item with your dropdown outside of it. That could cause compatibility issues, however.
Just give your list item a padding-left of 15px. The dropdown link has a default padding-left of 15px (you can find that in the navs.less file on line 23).

Related

bootstrap collapse menu has 2 rows

I am building this website
torgoborudovanie.com
I have a collapsing navbar build with bootstrap.But when I try to resize the window I get something like this :
As you can see (and you can actually try it ) nav bar now has 2 lines and it looks wired (the actual problem is that it looks like this on Iphone and Ipad) Then you can resize it a little bit more and it gets collapsed as I want.
You can see the code by simply viewing html code in developer tools.
So I will not post it here to make qustion clean and small.But if you want I can post the code here too=)
I ended up with this (quite shitty to be fair workaround)
On page load if I have window.width less than 1200px I just hide long text.
function hideSlogan() {
if($(window).width() <1200) {$('.slogan').hide()}
};
hideSlogan();
Go to the CSS rules starting at the MOBILE NAV comment; these are the rules you can adjust to make the navbar collapse at different breakpoints.
On a sidenote, there is one extra, broken list tag in the nav and with the positioning of Надежный партнер - качественные решения! inside your navbar-collapse div you'll the following behavior:
If you expand the menu when it's in the mobile and then expand the viewport your navbar will revert to the line-height: 60px unless the browser is refreshed. Might not matter but since you're trying to change the collapse breakpoint it's worth mentioning.
**I also moved the inline styles with the rest of the CSS Rules.
#import url(http://fonts.googleapis.com/css?family=Open+Sans:400, 700, 800);
#import url(http://fonts.googleapis.com/css?family=Libre+Baskerville:400italic);
* {
margin: 0;
padding: 0px;
font-family: 'Open Sans', sans-serif;
}
body {
background: #fff;
margin: 0;
color: #42413e;
padding-top: 50px;
}
/* BOOTSTRAP MODIFICATION */
.navbar-right a .btn-orange {
margin-top: -5px;
}
.btn-orange {
background: #f27242;
border-radius: 2px;
color: white;
font-size: 12px;
font-weight: 700;
}
.btn-orange:hover {
background: #e16a3e;
color: white;
}
.navbar-default .navbar-brand {
height: 50px;
padding: 10px 15px;
font-size: 20px;
line-height: 22px;
font-weight: 700;
}
.navbar.navbar-default {
background-color: #ffffff;
border-color: #e7e7e7;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #f27242;
background-color: transparent;
}
.navbar-default .navbar-nav > li > a {
color: #ccc;
}
.navbar-default .navbar-right {
padding-top: 5px
}
.navbar-default li.dropdown a {
color: black;
}
.navbar-default span.head-title {
line-height: 60px;
}
.navbar-default .navbar-right .dropdown-menu {
right: auto;
left: 0;
}
.navbar-right li.contact-info a {
color: #42413e;
}
/****MOBILE NAVBAR******/
#media (max-width: 1200px) {
.custom-navbar .navbar-header {
float: none;
}
.custom-navbar .navbar-left,
.custom-navbar .navbar-right {
float: none !important;
}
.custom-navbar .navbar-toggle {
display: block;
}
.custom-navbar .navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
overflow-x: hidden;
}
.custom-navbar.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.custom-navbar .navbar-collapse.collapse {
display: none!important;
}
.custom-navbar .navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.custom-navbar .navbar-nav > li {
float: none;
}
.custom-navbar .navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
}
.custom-navbar .collapse.in {
display: block !important;
}
.custom-navbar .navbar-nav .open .dropdown-menu {
position: static;
float: none;
width: auto;
margin-top: 0;
background-color: transparent;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.custom-navbar .navbar-brand {
height: 55px;
padding: 10px 15px;
font-size: 20px;
line-height: 22px;
font-weight: 700;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<nav class="navbar navbar-default custom-navbar navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Переключить навигацию</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img src="http://www.torgoborudovanie.com/assets/img/logo1.png" width="140">
</a>
</div>
<div class="collapse navbar-collapse"><span class="head-title">Надежный партнер - качественные решения!</span>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"> Каталог <span class="caret"></span>
<ul class="dropdown-menu">
<li>Стеллажи
</li>
<li>Торговая мебель
</li>
<li>Тележки и корзины
</li>
<li> Кассовые боксы
</li>
<li>Холодильное оборудование
</li>
<li role="separator" class="divider"></li>
<li>Условия доставки
</li>
</ul>
</li>
<li class="contact-info">
<i class="fa fa-phone "></i> 8 (343) 3448090
</li>
<li class="contact-info">
<i class="fa fa-envelope"></i> info#optimagp.ru
</li>
<li>
<a href="#f">
<button class="btn btn-sm btn-orange" type="button">Заказать звонок</button>
</a>
</li>
</ul>
</div>
</div>
</nav>
you need to change your breakpoint, when the navbar gets collapsed...
so for example, this should work:
#media only screen and (min-width: 1200px) {
.collapse {
display: block;
}
.navbar-toggle {
display: none;
}
}
#media only screen and (max-width: 1200px) {
.collapse {
display: none;
}
.navbar-toggle {
display: block;
}
}
because it floats (because its so long) after 1200px width...
** sorry, i made a mistake... try it now :) **

Bootstrap 3 collapsed menu flashes down on desktop

I have a Bootstrap 3 navbar. Everything works fine on mobile but at desktop size the "mobile" collapse version of the navbar flickers down when a nav link is clicked. I just don't want to be able to see this on the desktop.
You can view a bootply here.
I am fairly new to web development so I apologize if my code is unorganized or sloppy. The code is...
/* CSS used here will be applied after bootstrap.css */
.navbar {
height: 110px;
background-color: #f7f7f7;
width: 100%;
border-color: #f7f7f7;
}
.navbar-logo {
margin-top: 10px;
margin-left: 45px;
}
.navbar-social {
margin-top: 10px;
}
.navbar-social i {
float: left;
background: #ffffff;
color: #707070;
width: 30px;
height: 30px;
border: 1px solid #909090;
border-radius: 20px;
text-align: center;
margin-right: 10px;
padding-top: 10px;
}
.navbar-social > p {
float: right;
text-align: right;
color:#FF344E;
}
.navbar .nav-pills>.active>a:hover,.navbar .nav-pills>li>a:hover, .navbar .nav-pills>li>a:focus {
background-color: #f60756;
}
.navbar .nav-pills>.active>a,.navbar .nav-pills>.open>a,.navbar .nav-pills>.open>a, .navbar .nav-pills>.open>a:hover,.navbar .nav-pills>.open>a, .navbar .nav-pills>.open>a:hover, .navbar .nav-pills>.open>a:focus {
background-color: #f60756;
}
.dropdown-menu {
background-color: #f7f7f7;
}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus {
background-color: #f60756;
}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus {
background-image: none;
}
.navbar .navbar-brand {
color: #000000;
}
.navbar .navbar-brand:hover {
color: #FFFFFF;
}
/* fills in background on hamburger menu */
.navbar-collapse > ul {
background-color: #f7f7f7;
}
/* hamburger menu list */
.navbar .nav-pills>li {
margin: 10px;
font-size: 18px;
background-color: #f7f7f7;
}
/* hamburger menu list item */
.navbar .nav-pills>li>a {
color: #000000;
background-color: #f7f7f7;
}
.navbar .nav-pills .open .dropdown-menu>li>a, .navbar .nav-pills .open .dropdown-menu {
background-color: #f7f7f7;
color:#ffffff;
}
.navbar .nav-pills>li>a:hover, .navbar .nav-pills>li>a:focus {
color: #ffffff;
background-color: #f60756;
}
.navbar .nav-pills>.active>a,.navbar .nav-pills>.open>a, .navbar .nav-pills>.open>a:hover, .navbar .nav-pills>.open>a:focus {
color: #ffffff;
background-color: #f60756;
}
.navbar .nav-pills>.active>a:hover, .navbar .nav-pills>.active>a:focus {
color: #707070;
background-color: #f60756;
}
.navbar .dropdown-menu {
background-color: #f7f7f7;
color: #ffffff;
}
.dropdown-menu>li>a {
color: #333333;
}
.dropdown-menu>li>a:hover, .dropdown-menu>li>a:focus {
color: #FFFFFF;
}
.navbar .nav-pills>.dropdown>a .caret {
border-top-color: #999999;
}
.navbar .nav-pills>.dropdown>a:hover .caret {
border-top-color: #999999;
}
.navbar .nav-pills>.dropdown>a .caret {
border-bottom-color: #999999;
}
.navbar .nav-pills>.dropdown>a:hover .caret {
border-bottom-color: #999999;
}
/* hamburger menu colors */
.navbar .navbar-toggle {
border-color: #f60756; /* Change border color around this buttons */
background: #f60756; /* Change background for button itself */
}
.navbar .navbar-toggle .icon-bar {
background: #ffffff; /* Change color for horizontal lines */
}
.navbar-collapse.in {
overflow-y: none;
}
<div class="navbar navbar-fixed-top" role="banner">
<a href="./" class="col-xs-2 col-sm-2 col-md-2 navbar-logo">
<img alt="Brand" src="img/" height="100" width="100">
</a>
<div class="col-xs-6 col-xs-offset-1 col-sm-6 col-md-6 col-md-offset-0 col-lg-6 navbar-social">
<i class="fa fa-facebook"></i>
<i class="fa fa-twitter"></i>
<i class="fa fa-google-plus fa-lg"></i>
<!--TODO check vimeo for removal
<i class="fa fa-vimeo"></i> -->
<p>555.555.5555</p>
</div>
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<ul class="col-xs-6 col-xs-offset-8 col-sm-12 col-md-9 col-md-offset-1 nav navbar-nav nav-pills">
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#whyRadicalNav">Why Radical?</a>
</li>
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#whyGiraffeNav">Why Giraffe?</a>
</li>
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#towerNav">Tower</a>
</li>
<li>
Stories
</li>
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#contactNav">Contact</a>
</li>
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#">Blog</a>
</li>
</ul>
</nav>
</div>
That is because you are targeting navbar-collapse every time a link is clicked. Exactly why the navbar is behaving funny:
Bootply Link
instead of this:
<li>
<a data-toggle="collapse" data-target=".navbar-collapse" href="#contactNav">Contact</a>
</li>
go for this (do this for all the links):
<li>
Contact
</li>
<li>
Why Radical?
</li>
<li>
Why Giraffe?
</li>

Bootstrap (data toggle) drop down menu on navbar not displaying as a block

For some reason when I click the pancake button, I have been able to get the menu to display as a block using the z-index but on the list of elements of the menu. So the "block" is not the entire navbar but rather just the section that lists the links to the other pages and I ma not sure why. I have tried to drill into css and use block elements with no luck.
Here is the html for the navbar:
<nav class="navbar navbar-default">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target=".navbar-collapse" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/hug/">Hug a Tree</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav pull-right">
<li>about</li>
{% if user.is_authenticated %}
<li>profile</li>
<li>f<span style="color:#e48666">a</span>vourites</li>
<li>logout</li>
{% else %}
<li>register</li>
<li>login</li>
{% endif %}
</ul>
</div>
</nav>
And the css:
.navbar-default {
background-color: #fff;
border-color: #e9e7b6;
margin: 25px;
height: 100px;
}
.navbar-default .navbar-text {
font-family: 'Raleway', sans-serif;
}
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus {
font-family: 'Raleway', sans-serif;
color: #5aa47d;
}
.navbar-default .navbar-nav > .open > a, .navbar-default .navbar-nav > .open > a:hover, .navbar-default .navbar-nav > .open > a:focus {
font-family: 'Raleway', sans-serif;
color: #5aa47d;
}
.navbar-default .navbar-link {
font-family: 'Raleway', sans-serif;
color: #5c606b;
}
.navbar-default .navbar-link:hover {
font-family: 'Raleway', sans-serif;
color: #5aa47d;
}
.navbar-toggle {
margin-top: 33px;
}
ul.nav.navbar-nav.pull-right{
z-index: 2;
position: relative;
}
.nav.navbar-nav.pull-right li{
display: block;
z-index: 1;
background-color: #fff;
}
/*** navbar - icon ***/
img.brand {
display: block;
margin-left: auto;
margin-right: auto;
}
/*** navbar - brand/logo ***/
.navbar-default .navbar-brand{
font-family: 'Oswald', sans-serif;
float: left;
color: #426085;
padding: 35px 15px 0px 25px;
height: 50px;
font-size: 30px;
line-height: 25px
}
.navbar-default .navbar-brand:focus, .navbar-default .navbar-brand:hover{
color: #5aa47d;
}
/*** navbar - list ***/
.navbar-default .navbar-nav > li > a {
font-family: 'Raleway', sans-serif;
font-size: 16px;
color: #5c606b;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus, .navbar-default .navbar-nav > li > a:active {
font-family: 'Raleway', sans-serif;
color: #5aa47d;
}
.navbar-nav>li>a {
padding-top: 39px;
padding-right: 20px;
}
Any insight would be great.
Thanks.
I think this is what you're trying to do jsfiddle
pull-right was deprecated as of v3.1.0 and replaced with navbar-right.
Alexis Jensen Hi there. You are using a class pull-right in this line of code...
<ul class="nav navbar-nav pull-right">
If you remove the pull-right class it will expand across.
Is that all you were wanting here?

Bootstrap: How do I keep the navigation from truncating?

I am working on a Bootstrap 3 site and have everything working except the main menu. It has a hair trigger when it comes to resizing and truncates well in advance of the overall page sizing and quickly drops the last two navigation items to the next row, disrupting the slider, before it adjusts to the mobile navigation.
The page can be found here.
The HTML is as follows:
<!-- Navigation -->
<div class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div><!-- navbar-header -->
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Our Attorneys</li>
<li>Business Ligitagion</li>
<li>Personal Injury</li>
<li>Verdicts & Settlements</li>
<li>Client Testimonials</li>
<li>Map & Directions</li>
</ul>
</div><!--/.nav-collapse -->
</div><!-- container -->
</div><!-- navbar -->
The CSS:
/* #group navigation */
.navbar {
position: relative;
min-height: 35px;
margin-bottom: 0;
}
.navbar-default {
background-color: #9d2024;
border: none;
height: 25px;
}
#media (max-width: 767px) {
.navbar-default {
min-height:50px;
}
}
.navbar-default .navbar-brand {
color: #fff;
}
.navbar-default .navbar-brand:hover,
.navbar-default .navbar-brand:focus {
color: #fff;
border-bottom: 6px solid #fff;
}
.navbar-default .navbar-text {
color: #fff;
}
.navbar-default .navbar-nav > li > a {
color: #fff;
padding: 3px 10px;
margin: 5px 0 0 0;
border-right: 1px solid #fff;
font-family: trebuchet ms;
text-transform: uppercase;
}
.navbar-default .navbar-nav > li:last-child > a {
border: none;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #fff;
border-bottom: 4px solid #fff;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #fff;
border-bottom: 4px solid #fff;
background-color: #9d2024;
}
If I remove the container the navigation floats to the far left and does not flow with the page. I could use some insight for getting the navigation to resize properly without truncating.
You need yo use right bootstrap structure.
Problem is here:
row bannerand row slider-bg divs classes. Just remove row name and all need to work.
Error reason of start building a bootstrap is put a row of parent of container class. Container is first wrapping class in bootstrap, then comes row and then cols
For menu use smaller font size or inner li, a paddings.

Fixing ul to right of bootstrap navbar

Disclaimer: Pardon my stupidity when it comes to coding. I started learning last week.
I have been tinkering around with a Bootstrap 3 template from a Youtube tutorial I found to assist me in learning HTML, CSS, and eventually Java. In this example I'm working on, I am trying to get the inline unordered list to float to the right of the page. I tried adding float:right to most of the navbar elements in the CSS, but it's not doing anything for me. Any help would be greatly appreciated.
HTML:
<div class="navbar navbar-fixed-top">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button class="navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><img src="images/logo.png" alt="Your Logo"></a>
<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li class="active">
Home
</li>
<li class="inactive">
Photos
</li>
<li class="inactive">
Videos
</li>
<li class="inactive">
Contact Us
</li>
</ul>
</div><!-- end nav-collapse -->
</div><!-- end container -->
</div><!-- end navbar -->
CSS:
.navbar {
position: relative;
min-height: 50px;
padding-right: 15px;
padding-left: 15px;
margin-bottom: 20px;
background-color: #eeeeee;
border-radius: 4px;
}
.navbar:before,
.navbar:after {
display: table;
content: " ";
}
.navbar:after {
clear: both;
}
.navbar:before,
.navbar:after {
display: table;
content: " ";
}
.navbar:after {
clear: both;
}
.navbar-nav {
margin-top: 10px;
margin-bottom: 15px;
}
.navbar-nav > li > a {
padding-top: 15px;
padding-bottom: 15px;
line-height: 20px;
color: #777777;
border-radius: 4px;
}
.navbar-nav > li > a:hover,
.navbar-nav > li > a:focus {
color: #333333;
background-color: transparent;
}
.navbar-nav > .active > a,
.navbar-nav > .active > a:hover,
.navbar-nav > .active > a:focus {
color: #555555;
background-color: #d5d5d5;
}
.navbar-nav > .disabled > a,
.navbar-nav > .disabled > a:hover,
.navbar-nav > .disabled > a:focus {
color: #cccccc;
background-color: transparent;
}
.navbar-nav.pull-right {
width: 100%;
}
.navbar-static-top {
border-radius: 0;
}
.navbar-fixed-top,
.navbar-fixed-bottom {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
border-radius: 0;
}
.navbar-fixed-top {
top: 0;
}
.navbar-fixed-bottom {
bottom: 0;
margin-bottom: 0;
}
.navbar-brand {
display: block;
max-width: 200px;
padding: 15px 15px;
margin-right: auto;
margin-left: auto;
font-size: 18px;
font-weight: 500;
line-height: 20px;
color: #777777;
text-align: center;
}
.navbar-brand:hover,
.navbar-brand:focus {
color: #5e5e5e;
text-decoration: none;
background-color: transparent;
}
.navbar-toggle {
position: absolute;
top: 9px;
right: 10px;
width: 48px;
height: 32px;
padding: 8px 12px;
background-color: transparent;
border: 1px solid #dddddd;
border-radius: 4px;
}
.navbar-toggle:hover,
.navbar-toggle:focus {
background-color: #dddddd;
}
.navbar-toggle .icon-bar {
display: block;
width: 22px;
height: 2px;
background-color: #cccccc;
border-radius: 1px;
}
.navbar-toggle .icon-bar + .icon-bar {
margin-top: 4px;
}
As you are using Bootstrap, to so you may use class .pull-right to align it to right.
For more info click here.
In Bootstrap v 3.** it is better practice to use "navbar-right" so the proper context should read:
ul class = "nav navbar-nav navbar-right"
If you are using bootstrap 3 the use navbar-right to pull right h
jsfiddle.net/makk/9yxeg7r5/2 - this is a similar example
<div id="top"></div>
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="row">
<div class="navbar-header">
<a class="navbar-brand" href="#top"><span class="fa fa-book fa-3x">MATH</span></a>
</div>
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li>Features</li>
<li>Courses</li>
<li>Pricing</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>