A button can be created easily using the Bootstrap button classes. However, you need to left align or right align button to give its exact position on a page. But, what is the best way to left align button and right-align button using bootstrap class?
Well, you can easily align the button to the right position or to the left position with a single use of a bootstrap class.
Check the examples given below to find out different ways of button alignments.
How to Left Align Button Using Bootstrap
To left align button using bootstrap, you can use a bootstrap class
.text-left on a <div> tag and put Bootstrap button inside it.
See the below example for left alignment of button using bootstrap.
<button type="button" class="btn btn-primary">Left Aligned Button</button>
Right Align Button Using Bootstrap
For right alignment of button using bootstrap, you have to use the class
.text-right on a HTML div tag and put Bootstrap button inside it.
See the below example for right alignment of button using bootstrap.
<button type="button" class="btn btn-primary">Right Alignment</button>
The above example contains a primary button which is in the right position.
Center Alignment Using Bootstrap
In addition to above all, you can also align the button element center using Bootstrap. To center align the button, you have to use
.text-center as the class of the div element.
See the below example for center alignment of button element.
<button type="button" class="btn btn-primary">Center Aligned Button</button>
The above example contains the center aligned button.
Watch Our Live Demo and Download Code to Use
Conclusion: Do Not Use pull-right and pull-left For Button Alignment
If you are using the class
.pull-left, you are actually using the wrong class of bootstrap to align the button. Because these classes may break your design and float elements with other HTML elements and may.
So, use the above-given examples to always align a button to the desired positions.
Hope, you like this tutorial of how to align button to the left or right direction button using Bootstrap. If you have any query, please comment below.
Also tell me, which method are you using for button alignment using Bootstrap. Please leave a comment below.