Skip to content

Positioning

Utilities for controlling position type, inset coordinates, and z-index.

Position type

Classposition
staticstatic
relativerelative
absoluteabsolute
fixedfixed
stickysticky

Inset (all sides)

Classinset
inset-00
inset-autoauto

Offsets

ClassPropertyValue
top-0top0
top-50top50%
top-100top100%
top-autotopauto
bottom-0bottom0
bottom-50bottom50%
bottom-100bottom100%
bottom-autobottomauto
left-0left0
left-50left50%
left-100left100%
left-autoleftauto
right-0right0
right-50right50%
right-100right100%
right-autorightauto

Z-index

Classz-index
z-00
z-11
z-22
z-33
z-44
z-55
z-1010
z-5050
z-autoauto

Arbitrary values (JIT)

html
<div class="z-[100]">z-index: 100</div>
<div class="top-[50%]">top: 50%</div>
<div class="left-[calc(50%-8px)]">arbitrary offset</div>

Examples

html
<!-- Full-screen overlay -->
<div class="fixed inset-0 z-50 bg-black">
  Overlay
</div>

<!-- Absolute centering -->
<div class="relative" style="height: 200px">
  <div class="absolute top-50 left-50" style="transform: translate(-50%, -50%)">
    Centered in parent
  </div>
</div>

<!-- Sticky header -->
<header class="sticky top-0 z-10 bg-white elevation-4">
  Fixed header
</header>

<!-- Badge in corner -->
<div class="relative d-inline-block">
  <img src="avatar.jpg" />
  <span class="absolute top-0 right-0 bg-red text-white radius-pill pa-1">
    3
  </span>
</div>