Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get my Twitter Bootstrap buttons to right align?

I have a simple demo here:

<ul>     <li>One <input class="btn pull-right" value="test"></li>     <li>Two <input class="btn pull-right" value="test2"></li> </ul> 

I have an unordered list and for each list item I wish to have text on the left and then a right aligned button. I have tried to use pull-right but this completely messes up the alignment. What am I doing wrong?

<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" /> <ul>   <li>One <input class="btn pull-right" value="test"></li>   <li>Two <input class="btn  pull-right" value="test2" </li> </ul>
like image 843
deltanovember Avatar asked Mar 16 '13 06:03

deltanovember


People also ask

How do you align buttons to the right?

If you want to move the button to the right, you can also place the button within a <div> element and add the text-align property with its "right" value to the "align-right" class of the <div>.

How do you align buttons?

We can align the buttons horizontally as well as vertically. We can center the button by using the following methods: text-align: center - By setting the value of text-align property of parent div tag to the center. margin: auto - By setting the value of margin property to auto.

How do I keep my Bootstrap button centered?

Answer: Use the text-center Class You can simply use the built-in class . text-center on the wrapper element to center align buttons or other inline elements in Bootstrap. It will work in both Bootstrap 3 and 4 versions.


2 Answers

Insert pull-right into the class attribute and let bootstrap arrange the buttons.

For Bootstrap 2.3, see: http://getbootstrap.com/2.3.2/components.html#misc > Helper classes > .pull-right.

For Bootstrap 3, see: https://getbootstrap.com/docs/3.3/css/#helper-classes > Helper classes.


For Bootstrap 4, see: https://getbootstrap.com/docs/4.0/utilities/float/#responsive

The pull-right command was removed and replaced with float-right or in general to float-{sm,md,lg,xl}-{left,right,none}

like image 117
aronadaal Avatar answered Oct 08 '22 13:10

aronadaal


In twitter bootstrap 3 try the class pull-right

class="btn pull-right" 
like image 32
Shawn Vader Avatar answered Oct 08 '22 12:10

Shawn Vader