first time posting to StackOverflow and new developer, so please go easy on me :-)
I am using bootstrap to make a navbar on my site and am having an issue with the collapse dropdown menu.
Desktop screenshot As this is my first post, images are not allowed to be embedded.
As you can see, I have the logos nicely aligned on the right-hand side of the navbar.
My problems is that when viewed on a mobile screen/ smaller screen, the icons look messy when vertically stacked.Smaller viewing port screenshot
Ideally, I would like the icons to stay on one line in a way that does not jeopardize the overall style of how they look in full desktop mode.
Here is my HTML code, all using Bootstrap, no CSS have been altered:
`
<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="600">
<div class="container-fluid" id="navbarText">
<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="#" id="zara"></a>
</div>
<div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav" id="nav-options">
<li>About</li>
<li>Tools</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><span class="fa fa-envelope"></span>
</li>
<li><a><span class="fa fa-phone"></span></a>
</li>
<li><span class="fa fa-linkedin"></span>
</li>
<li><span class="fa fa-github"></span></li>
</ul>
</div>
</div>
</div>
</nav>
`
Thank you very much for any help.
Im trying to make a navbar but I need it to be from Right to Left cause its in Hebrew.
I tried making a responsive Navbar Where all the linked buttons are on the Left and Going Right.
And a Brand on the Right side.
And they collapse on Small devices.
Well I cant get it to reverse and I also sometimes get an issue where on small devices the Brand and the Collapse button collide in the middle of the navbar.
Well I fixed it by adding:
body{
direction: rtl;
}
to my css...
Thanks for the help and sorry for misleading you by my wrong title D:
Maybe you can use media query with the smallest query eg media query
example:
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Left</li>
</ul>
<ul class="nav navbar-nav navbar-center">
<li>Center</li>
<li>Center</li>
<li>Center</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Right</li>
</ul>
</div>
</nav>
#media (min-width: 240px) {
.navbar-nav.navbar-center {
position: absolute;
left: 50%;
transform: translatex(-50%);
}
This work fine for me.
<ul class="nav nav-tabs nav-justified" style="direction: rtl;">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
So I have bootstrap navbar which is fixed and have body padding-top: 50px;
so far so good but the bootstrap.js and .css files make clicked li background color to be white and i want it to be black i guess the default is white.So i tried to manually change background-color property of the .active class
HTML:
<header>
<nav class="navbar navbar-fixed-top">
<div class="container">
<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="#"><img id="logo-img" src="images/logo.png" alt="logo"></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li><span class="glyphicon glyphicon-search"></span> Search</li>
<li><span class="glyphicon glyphicon-home"></span> Sales</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><span class="fa fa-cogs"></span> Services</li>
<li><span class="glyphicon glyphicon-comment"></span> Contact</li>
<li><span class="glyphicon glyphicon-link"></span> About Us</li>
</ul>
</div>
</div>
</nav>
</header>
in custom CSS i have but nothing happens it does not change from white to black:
.active {
background-color: black !important;
}
Just changing the background of the .active class will not work
try the following:
ul.nav a:hover, ul.nav a:focus, ul.nav a:active { color: #000; }
I don't thing !important will be necessairy
In my web page I have a Bootstrap 3 navbar:
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#">Teachlab</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Home", '#' %></li>
<li><%= link_to "Help", '#' %></li>
<li><%= link_to "Sign in", '#' %></li>
</ul>
</div>
</nav>
<div class="container">
<%= yield %>
</div>
</body>
The problem is that navigation is to close to the edge of the screen. If I remove navbar-fixed-top from the navigation bar, it's working as I want.
Any hints?
Use .container-fluid as of 3.1.1.
The structure is not correct. .navbar-right goes on the .collapse container not on the ul.
SAMPLE: http://jsbin.com/eQIROsE/2/edit
<div class="navbar navbar-fixed-top navbar-default">
<div class="navbar-header">
<a class="navbar-brand" href="#">Project name</a>
<button type="button" class="navbar-toggle" 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>
<div class="navbar-collapse collapse navbar-right">
<ul class="nav navbar-nav">
<li class="active">Home
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
</div>
<!--/.navbar-collapse -->
</div>
I ended up with overriding following:
.navbar-nav.navbar-right:last-child {
margin-right: 0;
}
But maybe there's another solution?
It's broken and won't fix in 3.x. Hack it.
.navbar-right {
margin-right: 0px;
}
The solution to this could be
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" 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>
<a class="navbar-brand" href="#">Project name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>Default</li>
<li>Static top</li>
<li class="active">Fixed top</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
It worked for me.
I really can't see why you'd have two .navbar-nav.navbar-right. Just wrap the navs in .navbar-right instead.
<div class="navbar-right">
<ul class="nav navbar-nav">...</ul>
<ul class="nav navbar-nav">...</ul>
</div>
I got exactly the same issue today!
According to Bootstrap doc <ul class="nav navbar-nav navbar-right"> is correct.
Like you, I solved the problem by setting the nav navbar-nav navbar-right margin-right to 0px without noticing unwanted effects.
Notice that the margin-right value of .navbar-text.navbar-right:last-child is 0px while .navbar-nav.navbar-right:last-child margin-right value is -15px... Bizarre?
https://github.com/twbs/bootstrap/issues/13325
My not so elegant solution, but does the job very quickly, add a last list item;
<li><span> </span></li>
If you have problem with
margin-right: -15px;
in .navbar-right then just add in your css styles
.navbar-right {
margin-right: 0px;
}
and if this still doesn't work clear your browser from all history when your webstie was running and debug it again. It works :)
(Fixed in asp.net mvc)
I had the same problem in asp.net mvc c#, the way i fix it was by going to Contents/bootstrap.css i located the .navbar{} class and i add it a padding of 5 px,that worked for me.
Heres how it looks when you find it..
I'm having trouble with lining up the connections and sign out sections on my navbar toggle. As you can see, the last two are out of line with the others. I am using the bootstrap 3 site as a reference, but I'm sure I have something not marked right.
HTML
<nav class="navbar navbar-default" role="navigation">
<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="#">Site</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Dash</li>
<li>Edit Profile</li>
<li>Invite</li>
<li>Record A Message</li>
<li>
<p class="navbar-text">Connections <span class="badge">0</span></p>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<p class="navbar-text">Sign out as <a class="navbar-link" href="Login.aspx">User</a></p>
</li>
</ul>
</div>
<!-- /.navbar -->
</nav>
Thank you
I have tried a few different ways and the only solution I found without breaking the "mobile-first" approach was overriding the "navbar-text" class with a margin-left: 15px which also appears on the #media (min-width: 768px) line 4695.
.navbar-text {
margin-left: 15px;
}
I hope it helps ;)
trying removing the paragraph tags