Bootstrap is an open-source CSS-based framework. It is designed in a way to make web development easier for the developers. That is why it is the preferred framework of many users. You can have responsive websites by using this remarkable platform. This framework offers built-in classes for web front-end development. Thus, it is quite an effective framework for web developers.
We can utilize built-in classes of Bootstrap 4 for text alignment. These classes help to align the text to right, left, or center. We are going to explain the ways or classes that are helpful to align the text to the right. There are multiple ways in Bootstrap for aligning the elements to the right. Let us discuss these ways in detail.
1. Align right using
This class of Bootstrap utilizes the float property of the CSS for aligning the text in the
h2 tag to the right side of the page. Consider the point that the container in Bootstrap 4 is flexbox. It can stop the float property to work accordingly.
<h2 class="float-right">Align text to the right</h2>
2. Align right using the
It also assists in aligning the text to the right side on every viewport size. We usually implement it on inline elements.
<h2 class="text-right">Here is the right aligned text.</h2>
3. Align right by using
It is used to align all the items in flexbox container to the right side on the main axis. Keeping a point in mind that the display property must be set to flex while using this class. In bootstrap 4 it is the
<div class="d-flex flex-column align-items-end"> <p>product 1</p> <p>product 2</p> </div>
4. Align right using
It is commonly used on Flexbox children like nav-bars, columns, and some others.
<div class="d-flex"> <p class="btn btn-outline-primary ml-auto">button</p> </div>
5. Align right using
It helps to align the Flexbox’s single item to the right side.
<div class="d-flex flex-column"> <div>product 1</div> <div class="align-self-end">product 2</div> <div>product 3</div> </div>