Position

Bootstrap 5 Position

Use these helpers for quickly configuring the position of an element.

Basic examples

Use border utilities to add or remove an element’s borders. Choose from all borders or one at a time.

Fixed top

Position an element at the top of the viewport, from edge to edge. Be sure you understand the ramifications of fixed position in your project; you may need to add additional CSS.

											
												
											
										

Fixed bottom

Position an element at the bottom of the viewport, from edge to edge. Be sure you understand the ramifications of fixed position in your project; you may need to add additional CSS.

											
												
											
										

Sticky top

Position an element at the top of the viewport, from edge to edge, but only after you scroll past it. The .sticky-top utility uses CSS’s position: sticky, which isn’t fully supported in all browsers.

											
												
											
										

Responsive sticky top

Responsive variations also exist for .sticky-top utility.

											
												
											
										

Position values

Quick positioning classes are available, though they are not responsive.

											
												
											
										

Arrange elements

Arrange elements easily with the edge positioning utilities. The format is {property}-{position}.

Where property is one of:

  • top - for the vertical top position
  • start - for the horizontal left position (in LTR)
  • bottom - for the vertical bottom position
  • end - for the horizontal right position (in LTR)

Where position is one of:

  • 0 - for 0 edge position
  • 50 - for 50% edge position
  • 100 - for 100% edge position

(You can add more position values by adding entries to the $position-values Sass map variable.)

.top-0 .start-0
.top-0 .end-0
.top-50 .start-50
.bottom-50 .end-50
.bottom-0 .start-0
.bottom-0 .end-0

                            
                              
                            
                          

Center elements

In addition, you can also center the elements with the transform utility class .translate-middle.

This class applies the transformations translateX(-50%) and translateY(-50%) to the element which, in combination with the edge positioning utilities, allows you to absolute center an element.


                            
                              
                            
                          

Additional examples

You can use these classes with existing components to create new ones. Remember that you can extend its functionality by adding entries to the $position-values variable. .