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
Image placeholderImage placeholder
Image placeholderImage placeholder

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

.object-topobject-position: top center
Image placeholderImage placeholder
Image placeholderImage placeholder

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

.object-rightobject-position: center right
Image placeholderImage placeholder
Image placeholderImage placeholder

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

.object-bottomobject-position: bottom center
Image placeholderImage placeholder
Image placeholderImage placeholder

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

.object-leftobject-position: center left
Image placeholderImage placeholder
Image placeholderImage placeholder

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

.object-top-leftobject-position: top left
Image placeholderImage placeholder
Image placeholderImage placeholder

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

.object-top-rightobject-position: top right
Image placeholderImage placeholder
Image placeholderImage placeholder

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

.object-bottom-leftobject-position: bottom left
Image placeholderImage placeholder
Image placeholderImage placeholder

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

.object-bottom-rightobject-position: bottom right
Image placeholderImage placeholder
Image placeholderImage placeholder

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

.position-staticposition: static
Element Before
Target
Element After

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

.position-relativeposition: relative
Element Before
Target
Element After

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

.position-absoluteposition: absolute
Target

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 down ↓
Sticky target
The target scrolls normally until it reaches the top edge.

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
Target

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
Target

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
Target

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
Target

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

.top-0top: 0
Target

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

.right-0right: 0
Target

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

.bottom-0bottom: 0
Target

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

.left-0left: 0
Target

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

.top-autotop: auto
Target

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

.right-autoright: auto
Target

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

.bottom-autobottom: auto
Target

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

.left-autoleft: auto
Target

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

.top-halftop: 50%
Target

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

.right-halfright: 50%
Target

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

.bottom-halfbottom: 50%
Target

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

.left-halfleft: 50%
Target

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%)
Target

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%)
Target

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%)
Target

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
Target

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
Target

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
Target

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
Target

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
Target

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
Target

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
Target

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

.z-basez-index: 0
Target · z-index: 0
Reference · z-index: 1

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

.z-contentz-index: 1
Target · z-index: 1
Reference · z-index: 1

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

.z-dropdownz-index: 100
Target · z-index: 100
Reference · z-index: 1

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

.z-stickyz-index: 200
Target · z-index: 200
Reference · z-index: 1

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

.z-header-navz-index: 250
Target · z-index: 250
Reference · z-index: 1

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

.z-overlayz-index: 300
Target · z-index: 300
Reference · z-index: 1

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

.z-modalz-index: 400
Target · z-index: 400
Reference · z-index: 1

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

.z-toastz-index: 500
Target · z-index: 500
Reference · z-index: 1

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

.isolateisolation: isolate
Child · z-index: 10
Outside sibling · z-index: 1

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
Child · z-index: 10
Outside sibling · z-index: 1

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.

NextEffectsExplore effects classes and how to use them.