How to align-right in Bootstrap 4

Bootstrap is a CSS framework used to design and customize responsive, mobile-first sites.

In Bootstrap 4, aligning elements to the right can be achieved using any of the following classes:

Adding float-right class

The .float-right class in Bootstrap uses the CSS float property to place an element on the right. Note that the Bootstrap 4 container is a Flexbox that can prevent the float property from working.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Using justify-content-end class

The .justify-content-end class is used on Flexbox containers to align all items on the main axis to the right. Always remember that the container using this class must have its display property set to flex. This is the .d-flex class in Bootstrap 4.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Adding a align-items-right class

The .align-items-end class is used on Flexbox containers to align all items along its cross axis (i.e., vertically) to the right. The.d-flex class is required here, and the flex direction of the parent container should be set to column.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

See how the classes mentioned above work in the widget. Click "Run" to see the output.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Using .align-self-end class

.align-self-end is used to align a single item in a Flexbox to the right.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Using text-right class

text-right aligns text to the right on all viewport sizes. This is mostly used on inline elements.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Adding ml-auto class

The .ml-auto class is mostly used on columns, nav-bars, and a few other Flexbox children.

The result of applying all the classes above is mentioned below:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Free Resources