Skip to content

Position ​

Utilities for controlling how an element is positioned in the DOM.

Class NameCSS Equivalent
staticposition: static;
relativeposition: relative;
absoluteposition: absolute;
fixedposition: fixed;
stickyposition: sticky;

Static Position ​

The .static class sets the position property to static. This is the default positioning for an element in the normal flow of the document.

Static parent
Absolute child
html
<div class="static">
  <!-- Element with static position -->
</div>

Relative Position ​

The .relative class sets the position property to relative. It allows you to position an element relative to its normal position in the document flow.

Relative parent
Absolute child
html
<div class="relative">
  <!-- Element with relative position -->
</div>

Absolute Position ​

The .absolute class sets the position property to absolute. It allows you to position an element relative to its nearest positioned ancestor. Use absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

Any offsets are calculated relative to the nearest parent that has a position other than static, and the element will act as a position reference for other absolutely positioned children.

With static positioning
Relative parent
Static parent
Static child
Static sibling
With absolute positioning
Relative parent
Static parent
Absolute child
Static sibling
html
<div class="absolute">
  <!-- Element with absolute position -->
</div>

Fixed Position ​

The .fixed class sets the position property to fixed. It allows you to position an element relative to the viewport, so it remains in the same position even when the page is scrolled.

Any offsets are calculated relative to the viewport and the element will act as a position reference for absolutely positioned children.

html
<div class="fixed">
  <!-- Element with fixed position -->
</div>

Sticky Position ​

The .sticky class sets the position property to sticky. It allows an element to stick to the nearest scrolling ancestor or the viewport once it reaches a specified scroll position.

html
<div class="sticky">
  <!-- Element with sticky position -->
</div>