Navigation with Bootstrap - html

I created a navbar with Twitter-Bootstrap but I'm having trouble with my navigation.
I want to create navigation where nav is on the left and my logo on the right. I created the .nav-head-middle div with vertical-align:middle; and display:inline-block; so that my navigation and logo are on the same line (i.e. the middle).
My navigation and logo are on the same line but my problem is that my logo isn't on the right.
HTML
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="nav-head-middle">
<ul class="nav navbar-nav nav-adelva">
<li>HOME</li>
<li>ABOUT US</li>
<li>SERVICES</li>
<li>PARTNERS</li>
<li>CLIENTS</li>
<li>NEWS</li>
<li>CAREER</li>
<li>CONTACT</li>
</ul>
</div>
<div class="nav-head-middle">
<div class="navbar-right">
<img src="image/logo.png" />
</div>
</div>
</div> <!--/container -->
</div> <!--/navbar -->
CSS
.nav-head-middle{
display:inline-block;
vertical-align:middle;
}

Your problem could reside in not specifying the first set of navigation tabs to float left.
In CSS you need to tell the parts on the left to "go left" and the parts on the right to "go right".
In your case, with using bootstrap, you should utilize the built in code as apposed to creating extra custom CSS. The build in classes that should help are "navbar-left" and "navbar-right".
Not sure if this HTML will work for you or if it will help clarify your troubles, but I would think the html code should look closer to this:
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<ul class="nav nav-navtabs navbar-left">
<li>HOME</li>
<li>ABOUT US</li>
<li>SERVICES</li>
<li>PARTNERS</li>
<li>CLIENTS</li>
<li>NEWS</li>
<li>CAREER</li>
<li>CONTACT</li>
</ul>
<ul class="nav nav-tabs navbar-right">
<li><img src="image/logo.png" /></li>
</ul>
</div> <!--/container -->
</div> <!--/navbar -->

Related

Logo does not fit navbar

i followed the bootstrap way to build a navbar and a footer, but i am having some troubles with the navbar, i want to place an image that is my logo inside the navbar at the begining in the left, but the logo does not fit the column. I don't know why.
here is my code:
<header>
<nav class="navbar navbar-default">
<ul class="nav navbar-nav navbar-left">
<img src="img/logo1.png" class="img img-responsive" alt="">
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Register</li>
<li>Login</li>
</ul>
</nav>
</header>
Image:
i tried to add this css:
.navbar-brand
{
margin: 0;
padding: 0;
}
.navbar-brand img
{
max-height: 100%;
}
but then my image get to small, if i want to increase the size of the image the image stretch, i just want the image to maintain the size ratio, and fit the left side of the navbar, what is wrong here?
bootply
Put navbar-brand outside of navbar-nav
<header>
<nav class="navbar navbar-default">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img src="img/logo1.png" class="img img-responsive" alt="">
</a>
</div>
<ul class="nav navbar-nav navbar-left">
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Register</li>
<li>Login</li>
</ul>
</nav>
</header>
More Info
You can try this..
.navbar-brand
{
padding-left:20px;
z-index:999;
position:relative;
}

Navigation Bar with Bootstrap

i wanna make "block color" on my navigationbar with bootstrap. like this :
i used nav-pills for that. but i got nothing. block color is not showing. This is my code :
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav nav-pills">
<li>Home</li>
<li>Service</li>
<li>Gallery</li>
<li>Contact</li>
<li>About us</li>
</ul>
</div>
</nav>
Use the following CSS
.navbar.navbar-default {overflow: hidden; padding: 10px; background-color: #fff; border: 0;}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav nav-pills">
<li>Home</li>
<li>Service</li>
<li>Gallery</li>
<li>Contact</li>
<li>About us</li>
</ul>
</div>
</nav>
Use navbar-nav instead of nav-pills

How to put three or more images at navbar-right (Bootstrap)

I am creating a navbar with Bootstrap, the problem is when I try to put two or more images in the right navigation bar, the height of the bar increases how can i fix it? Thanks!!
<ul class="nav navbar-nav navbar-right">
<li><a href="http://www.youtube.es/"><img src="IMAGENES/youtube.png"/></li>
<li><a href="http://www.twitter.es/"><img src="IMAGENES/twitter.png"/></li>
<li><a href="http://www.facebook.es/"><img src="IMAGENES/facebook.png"/></li>
</ul>
Try like this: Demo
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header pull-left"> <a class="navbar-brand" href="index.php">xxx</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><img src="IMAGENES/youtube.png"/>
</li>
<li><img src="IMAGENES/twitter.png"/>
</li>
<li><img src="IMAGENES/facebook.png"/>
</li>
</ul>
You didn't closed <a> tags .. Check all the tags were closed properly or not..

Bootstrap position menu top right

I am looking on how to position my top navigation on the top right.
So far I have this code:
<div id="navbar" class="navbar navbar-fixed-top ">
<ul class="nav navbar-nav">
<li>Contact Us</li>
<li>NL</li>
<li>ENG</li>
</ul>
</div>
But I am not sure how to position it on the top right.
Thanks.
The right way to do this according to bootstrap is using the class navbar-right. Have a look at this link on bootply.
Try the following:
<div id="navbar" class="navbar navbar-fixed-top">
<ul class="nav navbar-nav navbar-right">
<li>Contact Us</li>
<li>NL</li>
<li>ENG</li>
</ul>
</div>
Update. Made a mistake and placed navbar-right on the div instead of the ul. It's fixed now. Also included bootply link.

Unable to fix the width in twitter bootstrap

It's the first time I'm using twitter bootstrap.
I wanted to limit the size to 940 px, and for that I used the span12 class.
But it doesn't seems to be working. Whole content is spread wide across the page.
What do I do to fix it ?
Here's the code :-
<body>
<div class="container">
<div class="row">
<div class="span12">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<ul class="nav">
<li class="active">Home</li>
<li>Find Your Mac</li>
<li>How it Works</li>
<li>About Us</li>
<li>Contact Us</li>
<li>FAQ</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</body>
The navbar is fixed at the top of the page. Even though the span12 has a width:940px since the navbar is affixed to the top, it takes 100% width.
To fix this apply the width to .navbar-fixed-top as below
.navbar-fixed-top{
margin: 0 auto; //to align horizontally in center
width: 940px;
}
The easiest way will be to put a <div class="container">, a <div class="row">, and a a <div class="span12"> inside the fixed navbar. Since the navbar is position: fixed;, it's removed from the normal flow of the page. You'll need to define the containment inside the navbar. After that it hardly seems worth keeping it nested in the original ones, so may as well make them siblings. So, like this:
<div class="navbar navbar-fixed-top">
<div class="container">
<div class="row">
<div class="span12">
<div class="navbar-inner">
<ul class="nav">
<li class="active">Home</li>
<li>Find Your Mac</li>
<li>How it Works</li>
<li>About Us</li>
<li>Contact Us</li>
<li>FAQ</li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="span12">
<!-- page content -->
</div>
</div>
</div>
You may need to adjust the specific nesting, but this should fix the immediate issue.