Frankie Frankie - 8 days ago 6
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

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

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

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.

Comments