Bootstrap buttons are no different from any other DOM elements of an HTML document. Aligning them is more likely the same as aligning paragraphs, divs and sections. Here are some of the scenarios that one can encounter.
- Buttons in ‘container’ class:
Buttons in ‘container’ class can be aligned with the ‘text-align’ properties. Wrap the group of buttons inside a div and align them using the following classes,
Note: You can also use HTML5 <center> tag to align buttons to the center.
- Buttons inside FlexBox:
- .d-flex .flex-row
- .d-flex .flex-column
Another way of arranging buttons is by using flex-utilities. The basic flex classes provided by Bootstrap are
The following pattern can be achieved by choosing either one of them.
- Relative-Absolute method:
- Vertical alignment in Bootstrap with Examples
- BootStrap | Text Utilities (Alignment, Wrapping, Weight etc.)
- Bootstrap 4 | Button Groups
- How to place button in top Right corner using bootstrap?
- How to enable Bootstrap tooltip on disabled button ?
- How to align button to right side of text box in Bootstrap?
- How to load notification alert on top right corner without click of button in bootstrap ?
- button tag vs input type="button" attribute
- Include Bootstrap in AngularJS using ng-bootstrap
- HTML | button Tag
- Button in Kotlin
- jQuery | :button Selector
- How to check a radio button with jQuery?
- How to change an input button image using CSS?
- How to know which radio button is selected using jQuery?
This is the most used method present online. In this case, the parent div is assigned a position ‘relative’ while the child divs are assigned position ‘absolute’.
Elements inside ‘absolute’ divs can be aligned in whatever way you want. Consider the following example. It shows all possible alignments a DOM element, in this case, buttons can have.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.