How to select my bootstrap navbar links for proper positioning? - html

So I have a bootstrap navbar, and I have been previously selecting the links with a span class of "nav-text". This is working for the font-size and color, but when I try applying a margin or padding I can not get a response. I have tried selecting the links for positioning in many, many different ways now so I've turned here.
Here is the html:
<ul class="nav navbar-nav navbar-right">
<li><span class="nav-text">Physicians</span></li>
<li><span class="nav-text">Directions</span></li>
<li><span class="nav-text">Services</span></li>
<li><span class="nav-text">FAQ</span></li>
<li><span class="nav-text">Privacy</span></li>
<li><span class="nav-text">Health Links</span></li>
<li><span class="nav-text">Office Policy</span></li>
<li><span class="nav-text" id="view">W***** Login</span></li>
</ul>
So how would I give the .nav-text links proper positioning? I was succesful in giving the #view id link a padding left. But the padding top doesn't work for that either?
Here is the entire navbar if you need it (bootstrap)
<header>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="index.php"><img src="#" id="logo"></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><span class="nav-text">Physicians</span></li>
<li><span class="nav-text">Directions</span></li>
<li><span class="nav-text">Services</span></li>
<li><span class="nav-text">FAQ</span></li>
<li><span class="nav-text">Privacy</span></li>
<li><span class="nav-text">Health Links</span></li>
<li><span class="nav-text">Office Policy</span></li>
<li><span class="nav-text" id="webview">Webview Login</span></li>
</ul>
</div>
</div>
</nav>
</header>
Fiddle

To add padding/margin to your links use:
.nav li a {
padding: 45px;
margin-right: 20px;
}
For example.
Your updated jsFiddle

Related

Bootstrap dropdown menu in navbar: align icons horizontally instead of being vertically stacked

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.

Bootstrap - reversing my navbar to Right-to-Left

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>

bootstrap navbar change active li background color manually

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

Bootstrap 3 navigation bar right margin is not supposed to be -15px

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..

bootstrap 3 navbar toggle collapse content not lining up evenly

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