Frankie Frankie - 1 year ago 167
CSS Question

Bootstrap pull-right badge in a list

I use bootstrap 3.3.7 and in my sidebar I have a list from php while function.

To print a value and formatting for bootstrap use this:

<li><a href="page.php?home=<?php echo $home_id; ?>"><?php echo $home_desc; ?></a><span class="badge">10</span></li>

With this code, I have the result in below image.

enter image description here

I have try some solution on stackoverflow answers but not work for me. How to pull right the badge?

Answer Source

You said you want to pull it to the right, but you haven't added anything. Try adding the pull-right class like this:

  <span class="badge pull-right">10</span>
  <!----------------^^^^^^^^^^^ -->
  <a href="page.php?home=<?php echo $home_id; ?>"><?php echo $home_desc; ?></a>

The pull-right class is one of the quick float helper classes, applies float: right to the elements and will give you the desired effect.