Position
Bootstrap 5 Position
Use these helpers for quickly configuring the position of an element.
Basic examples
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, as it might require additional CSS adjustments.
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, as it might require additional CSS adjustments.
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 verticaltop
positionleft
- for the horizontalleft
positionbottom
- for the verticalbottom
positionright
- for the horizontalright
position
Where position is one of:
0
- for0
edge position50
- for50%
edge position100
- for100%
edge position
You can add more position values by adding entries to the $position-values
Sass
map variable.
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
Here are some real life examples of these classes:
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.
Object Fit
It's an utility for controlling how the content of the replaced element is resized.
Resize the content of an item to cover its container with .object-cover
.

object-fit: cover;
Object Position
These are tools for controlling how the content of the replaced item should be placed in its container.
To specify how the contents of the replaced element should be placed in its container, use classes .object-top
, .object-center
or .object-bottom
.

object-position: top;

object-position: center;

object-position: bottom;