Skip to content

Positioning

Take elements out of the flow and place them precisely.

Position

Each position value is a standalone class.

ClassCompiles toPositions the element relative to
staticposition: staticNothing. It stays in the normal flow (the default)
relativeposition: relativeIts own normal spot
absoluteposition: absoluteThe nearest positioned ancestor
fixedposition: fixedThe viewport
stickyposition: stickyIts scroll container, once it reaches the offset you set
initialposition: initialResets to the default
inheritposition: inheritCopies the parent’s position

Offsets

PropertyCompiles toExample
top, right, bottom, leftThat sidetop:d4
insetAll four sidesinset:d0
inset-inline, inset-inline-start, inset-inline-endLogical inline sidesinset-inline:d4
inset-block, inset-block-start, inset-block-endLogical block sidesinset-block-start:d2

All of them take a spacing token or a sizing keyword like 0 or auto. inset also takes two values: inset:d2:d4 sets left and right to d2, top and bottom to d4.

A badge pinned to a card's corner
<div class="relative">
<span class="absolute top:d2 right:d2">New</span>
</div>
A header that sticks to the top
<header class="sticky top:0 z:10">…</header>

Stacking

PropertyValuesCompiles toExample
zAny numberz-indexz:10

Float and clear

PropertyValuesCompiles toExample
floatleft, right, none, inline-start, inline-endfloatfloat:inline-start
clearnone, left, right, both, inline-start, inline-endclearclear:both

Empty content

::before and ::after only render when they have content. The empty class sets content: '', so a state block can draw a purely decorative pseudo-element.

<span class="relative @after:[empty_absolute_inset:0_bg-color:indigo]">…</span>