Bootstrap spacing of links on navbar - html

I'm looking to add a bit of spacing between my username and logout button as well as my login and signup button.
I've tried adding spaces (doesn't do anything) and I've also tried using list items and inserting an empty paragraph tag. What can I do to add two or three horizontal spaces?
<ul class="nav navbar-nav navbar-right">
<div style="margin-right: 10px; margin-left: 15px; margin-top: 15px; margin-bottom: 5px;" class="container-fluid">
{% if session.logged_in %}
Welcome {{session['username']}}
<span class="glyphicon glyphicon-log-out"></span> Logout
{% else %}
<span class="glyphicon glyphicon-log-in"></span> Login
<span class="glyphicon glyphicon-pencil"></span> Sign up
{% endif %}
</div>
</ul>
These items are wrapped in
<div id="navbar" class="collapse navbar-collapse">
along with my other links on the left side.
Here's a picture of what I have now:
Current

To achieve expected result , use below two options
Option1:
Use unordered list tags ul , li
<ul class="nav navbar-nav navbar-right">
<li><span class="glyphicon glyphicon-user"></span> Sign Up</li>
<li><span class="glyphicon glyphicon-log-in"></span> Login</li>
</ul>
Option 2:
Use padding for the anchor tag with the existing code
<div class="row nav navbar-nav navbar-right test">
<span class="glyphicon glyphicon-user"></span> Sign Up<span class="glyphicon glyphicon-log-in"></span> Login
</div>
CSS:
.test a{
padding:10px;
}
For comparison, I have used both options in one codepen, please check it once
https://codepen.io/nagasai/pen/aypdXZ

I think you should apply a display: inline-block; or display: block; to <a></a> elements and then you can set the margins. That should do the work.
Or you can use <div></div> as their parent tag and then apply the margins to them. Just like that:
<div class="sample"><a></a></div>
And CSS:
sample {display:
inline-block;
}

Related

Hamburger button collapsing multiple divs

I have the following button:
<button type="button" class="navbar-toggle collapsed burger-button" data-toggle="collapse"
data-target="#bs-navbar-collapse-1,#bs-navbar-collapse-2" aria-expanded="false">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
And the following two divs:
<div class="collapse navbar-collapse list-links" id="bs-navbar-collapse-1" style=" margin-left: 25%;">
<ul class="nav navbar-nav navbar-right ">
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
</ul>
</div>
<div class="collapse navbar-collapse list-links ftr" id="bs-navbar-collapse-2"
style="width: 870px; margin: auto;">
<ul class="nav navbar-nav ">
<li>Fifth</li>
<li>Sixth</li>
</ul>
</div>
In the mobile version of the page, they both must not be seen and must be only reached through the hamburger button on top of the page. The problem is that both of the divs are hidden, but only the first one is seen, when the burger button is clicked.
Your example works for me. I tested it on Bootply in Firefox.
Please have a look: Bootply
I used Bootstrap (v3.3.7) and JQuery (v3.1.1)
Have you added the JQuery dependency to your project?
Instead of using multiple div tags, you can use multiple ul tags like that
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Fifth</li>
<li>Sixth</li>
</ul>
</div>
See that example in w3schools.
If you have to do that with multiple toggle-targets; it looks like in order to toggle-target to work, the target should be children of some nav element. So, if the second div is in the footer you may try to wrap it with a nav tag like this:
<footer>
<nav>
<div id="bs-navbar-collapse-2" ...>
...
</div>
</nav>
<footer>
Note that this may cause need for some other css work to prevent unwanted styling.

Add separator line in repsonsive Bootstrap navbar

I would like to add a separator line between menu items in the responsive Bootstrap navbar. I tried using border-bottom, but I need it to be inset on both sides. Here is what I am trying to achieve (the color is not the point here):
As you can see the line does not start from the edge of the screen.
How can I achieve this?
Here is my current code:
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><span class="glyphicon glyphicon-log-in hidden-on-mobile"></span> Belépés</li>
<li><span class="glyphicon glyphicon-user hidden-on-mobile"></span> Regisztráció</li>
</ul>
</div>
Apply the border to a pseudo element of the a in the tag, positioned with position: absolute and use the left and right values to account for the padding on that element so the border aligns with the text.
.nav>li>a:after {
content: '';
border-bottom: 1px solid red;
position: absolute;
bottom: 0; left: 15px; right: 15px;
}
/* you don't need this - just for the demo */
.collapse {
display: block!important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><span class="glyphicon glyphicon-log-in hidden-on-mobile"></span> Belépés</li>
<li><span class="glyphicon glyphicon-user hidden-on-mobile"></span> Regisztráció</li>
</ul>
</div>

Bootstrap Footer not Sticking to the bottom of the page

I'm using Bootstrap 3.3.5 to display a footer at the bottom of webpages using the .navbar navbar-default class. On pages which are displaying a list of items greater than 10 the footer is being displayed correctly at the bottom of the page but on pages having less than 5 items then the footer is being displayed at the middle of the page instead of the bottom.
HTML code..
<nav class="navbar navbar-default" style="margin-bottom:0px;padding-botton:0px">
<div class="container-fluid">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbarBottom">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse" id="myNavbarBottom">
<ul class="nav navbar-nav navbar-center">
<li><span class="glyphicon glyphicon-th-large"></span> About</li>
<li><span class="glyphicon glyphicon-pencil"></span> Blog</li>
<li><span class="glyphicon glyphicon-road"></span> How It Works</li>
<li><span class="glyphicon glyphicon-certificate"></span> Credits</li>
<li><span class="glyphicon glyphicon-earphone"></span> Contact</li>
<li><span class="glyphicon glyphicon-comment"></span><b style="color:blue;"> Survey</b></li>
</ul>
</div>
</div>
</nav>
After changing the navbar class to "navbar navbar-default navbar-fixed-bottom" the footer is fixed to the bootom of the page but I'm not able to scroll down to the last item of the list. Please help..
Try this...
.navbar{
position:absolute;
bottom:0;
width:100%;
}
ok so if you want footer to stick on scroll
then
.navbar
{
position: fixed;
bottom: 0;
width: 100%;
}
and if you just want footer
.navbar
{
position: absolute;
bottom: 0;
width: 100%;
}

2 navbar without space

I want to make something like this
When I made 2 navbar, there is a white gap separating them, how to remove this gap?
I've read somewhere that if I change the size of the navbar's elements will automatically increase its height , but it didn't work out.
If I need to make a custom class for a navbar, what properties should I change?
edit :
<nav class ="navbar topNavbar">
<div class="container-fluid">
<ul class="nav navbar-nav navbar-right">
<li><span class="glyphicon glyphicon-log-in"></span> Login </li>
<li><span class="glyphicon glyphicon-user"></span> Sign Up </li>
</ul>
</div>
</nav>
<nav class="navbar botNavbar">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="">Website name</a>
</div>
<div>
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Collections</li>
<li>About Us</li>
</ul>
</div>
</div>
</nav>
<style>
.topNavbar {
background-color: #F60;
}
.botNavbar {
background-color : #F90;
}
</style>
Bootstraps .navbar has a 20px bottom margin by default.
So you could do:
.topNavbar {
background-color: #F60;
margin-bottom: 0;
}
Bootply

Why I can't set width for nav tabs

I have navigation in div size col-md-4 , and I have 6 tabs, I can't to aline all tabs.
I can aline when I change font-size of text tabs, thats not good solution for me.
I tried to set width for each tabs, but not working.
How can I set width for some tabs to be small but second to be bigger.
Also i have padding when I hover on the end of navbar
http://i.imgur.com/9Px4qqk.png
<nav class="row">
<ul class="nav nav-tabs">
<li class="tab1"> <span class="glyphicon glyphicon-user"></span> Name &nbsp &nbsp<span class="glyphicon glyphicon-chevron-down"></span> </li>
<li><span class="glyphicon glyphicon-flag"></span>Text Link </li>
<li> <span class="glyphicon glyphicon-envelope"></span> Message </li>
<li> <span class="glyphicon glyphicon-oil"></span>10 </li>
<li class="tab5"><span class="glyphicon glyphicon-asterisk"></span> </li>
<li><span class="glyphicon glyphicon-home"></span> </li>
</ul>
</div>
CSS
.nav-tabs li .tab5{
width:4%;
}
Your selector is wrong, you have to do this:
.nav-tabs li.tab5 {
width: 4%;
}
The class .tab5 is on the li tag, therefore you have to connect them.
Working Example
UPDATE
If you want to fit all in one row, try playing with the padding, like this:
.nav>li>a {
padding: 10px 3px;
}
Updated Example