Positioning

Position elements with physical and writing-mode aware inset utilities.

Syntax

Use .position-relative, .position-absolute, .position-fixed, .position-static or .position-sticky to set the positioning context. The values inherit, initial and unset are available when an explicit reset is needed.

HTML
<div class="position-relative">
	<div class="position-absolute">Positioned content</div>
</div>

Class reference

Class or patternEffect
.position-{value}Sets relative, absolute, fixed, static, sticky, inherit, initial or unset positioning.
.inset-{value}Sets all physical offsets.
.inset-inline-{value}, .inset-block-{value}Sets both logical edges on an axis.
.inset-inline-start-{value}, .inset-inline-end-{value}Sets a logical inline edge.
.inset-block-start-{value}, .inset-block-end-{value}Sets a logical block edge.
.top-{value}, .right-{value}, .bottom-{value}, .left-{value}Sets one physical edge.
.fixed-topFixes the top edge across the viewport using --z-index-header.

Inset utilities set one or more offsets for a positioned element. The scale supports 0, 25, 50, 75, 100 percentages and auto.

Use the logical forms for layouts that must also work in right-to-left or vertical writing modes:

HTML
<div class="position-absolute inset-inline-0 inset-block-start-0">
	Pinned to the logical top edge
</div>

The physical .top-*, .right-*, .bottom-* and .left-* forms remain available for coordinates tied to the physical viewport or containing block.

HTML
<div class="position-fixed top-0 right-0">Physical top-right placement</div>

Responsive behavior

Inset utilities are mobile-first. Put the breakpoint before the scale, for example .inset-md-0, .inset-inline-lg-50 or .inset-block-end-xl-auto.

HTML
<div class="position-absolute inset-inline-0 inset-inline-md-50 inset-block-start-0">
	Responsive logical placement
</div>

Move a marker responsively

Inset utilities can change at a breakpoint. This marker starts at the logical inline start and moves toward the middle from md upward, while the panel content keeps its normal flow.

Responsive marker

Resize the page at the md breakpoint to see the marker move.

Example markup:

HTML
<div class="position-relative">
	<span
		class="badge position-absolute inset-inline-start-0 inset-inline-start-md-50 inset-block-start-0">
		Responsive marker
	</span>
	<p class="pt-3">Resize at the md breakpoint.</p>
</div>

Position classes themselves have no breakpoint variants. Inset percentages are relative to the containing block; they do not translate the element by its own size.

Recipes

Positioning is useful when one element belongs to another element’s bounds: badges can sit on a card corner, overlays can cover a panel, and controls can move without changing the surrounding flow.

Pin a badge to a card

Make the card the positioning context with .position-relative. The badge is then anchored to the logical end and block-start edges without affecting the card content.

Live

Deployment status

The badge stays attached to this card as its content changes.

Example markup:

HTML
<div class="card">
	<div class="card-body position-relative">
		<span
			class="badge bg-success position-absolute inset-inline-end-0 inset-block-start-0 m-3 z-index-1">
			Live
		</span>
		<h3 class="h5 mb-1">Deployment status</h3>
		<p class="mb-0 text-muted">The badge stays attached to this card.</p>
	</div>
</div>

Place an overlay over a panel

Use .inset-0 when an absolutely positioned element should cover its entire positioned parent. Keep the content above the overlay with a second positioned element and a z-index utility.

Panel overlay

The overlay fills the parent while the content remains readable.

Example markup:

HTML
<div class="position-relative rounded bg-secondary p-4 text-inverse">
	<div class="position-absolute inset-0 bg-primary rounded" aria-hidden="true"></div>
	<div class="position-relative z-index-1">
		<strong>Panel overlay</strong>
		<p class="mb-0 mt-1">The content stays above the overlay.</p>
	</div>
</div>