Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot get badge to line up with link in navbar

I am having trouble figuring out how to get a badge next to a link in my navbar and have it line up correctly.

<ul class="nav">
 <li><a href="#">Home</a></li>
 <li><a href="#">Link</a><span class="badge badge-important">4</span></li>

Here is a JSFiddle example of my problem: http://jsfiddle.net/pHRc9/3/

like image 855
lostintranslation Avatar asked Feb 16 '13 04:02

lostintranslation


2 Answers

Try putting the close of the a href outside of the span close.

<ul class="nav">
<li><a href="#">Home</a></li>
<li><a href="#">Link <span class="badge badge-important">4</span></a></li>

Updated Answer

You didn't specify that in your question. Using the code you have already existing, and placing this css worked okay for me.

a {
    float:left !important;
}
span {
    float: left !important;
    margin-top: 10px;
}
like image 159
thtsigma Avatar answered Oct 18 '22 05:10

thtsigma


Not sure why you would want the badge outside the link as the entire link becomes a block. The best way to have the badges to the right is similar to lostintranslation's answer, but instead of using .badge-important use .pull-right.

like image 41
alans Avatar answered Oct 18 '22 04:10

alans