Class Reference

Position

Class Reference

Position

Positioning, offsets, stacking order and image alignment.

How to use

Give an absolute element a position-relative ancestor. Fixed and sticky elements have different scroll behavior, and z-index must be considered alongside stacking contexts.

Responsive behavior

Positioning applies at all sizes unless a tablet or mobile variant is shown. Check smaller screens so positioned content does not cover controls or overflow the viewport.

Visual reference

Blue elements show the installed class behavior. Dashed outlines mark parent boundaries. Scroll interactive examples to see overflow, fixed, sticky, and anchor behavior.

.object-centerobject-position: center center

The same image uses cover in wide and narrow frames, so vertical and horizontal crop positions are visible.

.object-topobject-position: top center

The same image uses cover in wide and narrow frames, so vertical and horizontal crop positions are visible.

.object-rightobject-position: center right

The same image uses cover in wide and narrow frames, so vertical and horizontal crop positions are visible.

.object-bottomobject-position: bottom center

The same image uses cover in wide and narrow frames, so vertical and horizontal crop positions are visible.

.object-leftobject-position: center left

The same image uses cover in wide and narrow frames, so vertical and horizontal crop positions are visible.

.object-top-leftobject-position: top left

The same image uses cover in wide and narrow frames, so vertical and horizontal crop positions are visible.

.object-top-rightobject-position: top right

The same image uses cover in wide and narrow frames, so vertical and horizontal crop positions are visible.

.object-bottom-leftobject-position: bottom left

The same image uses cover in wide and narrow frames, so vertical and horizontal crop positions are visible.

.object-bottom-rightobject-position: bottom right

The same image uses cover in wide and narrow frames, so vertical and horizontal crop positions are visible.

.position-staticposition: static

Both examples receive top:16px and left:24px. Static ignores offsets; relative shifts visually while preserving its original space.

.position-relativeposition: relative

Both examples receive top:16px and left:24px. Static ignores offsets; relative shifts visually while preserving its original space.

.position-absoluteposition: absolute

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-fixedposition: fixed

Scroll inside this miniature viewport. Fixed positioning stays pinned to its viewport.

.position-stickyposition: sticky

Scroll inside the frame. A top: 0 offset is supplied so the sticky behavior is visible.

.inset-0top: 0 · right: 0 · bottom: 0 · left: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.inset-autotop: auto · right: auto · bottom: auto · left: auto

The preview supplies a 24px offset on this axis. This class resets it to auto, restoring the static-position reference.

.inset-x-0right: 0 · left: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.inset-y-0top: 0 · bottom: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.top-0top: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.right-0right: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.bottom-0bottom: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.left-0left: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.top-autotop: auto

The preview supplies a 24px offset on this axis. This class resets it to auto, restoring the static-position reference.

.right-autoright: auto

The preview supplies a 24px offset on this axis. This class resets it to auto, restoring the static-position reference.

.bottom-autobottom: auto

The preview supplies a 24px offset on this axis. This class resets it to auto, restoring the static-position reference.

.left-autoleft: auto

The preview supplies a 24px offset on this axis. This class resets it to auto, restoring the static-position reference.

.top-halftop: 50%

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.right-halfright: 50%

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.bottom-halfbottom: 50%

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.left-halfleft: 50%

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-centertop: 50% · left: 50% · transform: translate(-50%, -50%)

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-center-xleft: 50% · transform: translateX(-50%)

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-center-ytop: 50% · transform: translateY(-50%)

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-coverposition: absolute · top: 0 · right: 0 · bottom: 0 · left: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-toptop: 0 · right: 0 · left: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-bottomright: 0 · bottom: 0 · left: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-top-lefttop: 0 · left: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-top-righttop: 0 · right: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-bottom-leftbottom: 0 · left: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.position-bottom-rightright: 0 · bottom: 0

The dashed frame is a positioned parent. The target uses this class; offsets are measured from the parent’s edges.

.z-index-basez-index: 0

The two positioned elements overlap. The target uses this class; the reference always uses z-index:1.

.z-index-contentz-index: 1

The two positioned elements overlap. The target uses this class; the reference always uses z-index:1.

.z-index-dropdownz-index: 100

The two positioned elements overlap. The target uses this class; the reference always uses z-index:1.

.z-index-stickyz-index: 200

The two positioned elements overlap. The target uses this class; the reference always uses z-index:1.

.z-index-header-navz-index: 250

The two positioned elements overlap. The target uses this class; the reference always uses z-index:1.

.z-index-overlayz-index: 300

The two positioned elements overlap. The target uses this class; the reference always uses z-index:1.

.z-index-modalz-index: 400

The two positioned elements overlap. The target uses this class; the reference always uses z-index:1.

.z-index-toastz-index: 500

The two positioned elements overlap. The target uses this class; the reference always uses z-index:1.

.isolateisolation: isolate

The child has z-index:10. Isolate keeps that child inside its parent’s stacking context; auto allows it to overlap the outside sibling.

.isolation-autoisolation: auto

The child has z-index:10. Isolate keeps that child inside its parent’s stacking context; auto allows it to overlap the outside sibling.

.anchor-offset-nonescroll-margin-top: 0
Jump to target ↓
Reference header
Scroll content
Anchor target

Click Jump to target to see the class’s scroll margin. The reference header shows why an offset may be useful.

.anchor-offset-xsscroll-margin-top: var(--space-xs)
Jump to target ↓
Reference header
Scroll content
Anchor target

Click Jump to target to see the class’s scroll margin. The reference header shows why an offset may be useful.

.anchor-offset-smscroll-margin-top: var(--space-sm)
Jump to target ↓
Reference header
Scroll content
Anchor target

Click Jump to target to see the class’s scroll margin. The reference header shows why an offset may be useful.

.anchor-offset-mdscroll-margin-top: var(--space-md)
Jump to target ↓
Reference header
Scroll content
Anchor target

Click Jump to target to see the class’s scroll margin. The reference header shows why an offset may be useful.

.anchor-offset-lgscroll-margin-top: var(--space-lg)
Jump to target ↓
Reference header
Scroll content
Anchor target

Click Jump to target to see the class’s scroll margin. The reference header shows why an offset may be useful.