How do we make the vertical dividers in the navigation bar evenly spaced out?
Here's the HTML and CSS i'm currently using.
HTML:
<li class="divider-vertical"><a href = "#">Contact Us</a></li>
CSS:
.divider-vertical {
height: 50px;
margin: 0 9px;
border-left: 1px solid #F2F2F2;
border-right: 1px solid #FFF;
}
Navbar code:
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav">
<li><a href = "#">Home</a></li>
<li class="divider-vertical"><a href = "#">About</a></li>
<li class="divider-vertical"><a href = "#">Jobs</a></li>
<li class="divider-vertical"><a href = "#">Contact Us</a></li>
<li class="divider-vertical"><a href = "#">Resources</a></li>
</ul>
</div>
</nav>
There are several ways to achieve the effect you are after. Here is a quick fix that will solve your issue and give you the result you need.
.divider-vertical {
height: 50px;
margin: 0 0 0 9px;
padding: 0 0 0 9px;
border-left: 1px solid red;
}
A better approach which would save you a little html writing would be to do something like the following:
.divider-vertical
class from the HTML.li
elements, use margin
and padding
on the same side as your border
- in this case the right:last-child
to remove some css attributes from the last menu itemli {
border-right: 1px solid red;
margin: 0 9px 0 0;
padding: 0 9px 0 0;
}
li:last-child {
border-right: none;
}
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav">
<li><a href = "#">Home</a></li>
<li><a href = "#">About</a></li>
<li><a href = "#">Jobs</a></li>
<li><a href = "#">Resources</a></li>
</ul>
</div>
</nav>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With