Skip to main content

Position

Control how an element is positioned relative to it's container or viewport



Properties

Utility class Description
.position-static The default state. The element follows the normal document flow, and properties like top, bottom, left, and right have no effect.
.position-relative The element remains in the normal document flow, but you can offset it relative to its original position without affecting surrounding elements. It also establishes a reference point for any absolutely positioned child elements.
.position-absolute The element is removed from the normal document flow and creates no space for itself. It is positioned relative to its nearest "positioned" ancestor (one that is not static); if none exists, it is relative to the initial containing block (usually the body).
.position-fixed The element is removed from the normal flow and pinned relative to the browser viewport. It stays in the same place even when the page is scrolled, which is common for navigation bars or "back to top" buttons.
.position-sticky A hybrid that toggles between relative and fixed based on the user's scroll position. It behaves like a relative element until it reaches a specified threshold (e.g., top: 0), at which point it "sticks" to that position within its parent container while scrolling.

Static position

The default state. The element follows the normal document flow, and properties like top, bottom, left, and right have no effect.

Example

Normal flow: both boxes are static (default) and follow the document flow.
Attempted offset: adding top-1 to a static element does nothing — offset utilities only affect positioned elements (relative/absolute/fixed/sticky).

Relative position

The element remains in the normal document flow, but you can offset it relative to its original position without affecting surrounding elements. It also establishes a reference point for any absolutely positioned child elements.

Top

Utility class Value
.top-autoauto
.top-neg-3-24px
.top-neg-205-20px
.top-neg-2-16px
.top-neg-105-12px
.top-neg-1-8px
.top-neg-05-4px
.top-neg-2px-2px
.top-neg-1px-1px
.top-00
.top-1px1px
.top-2px2px
.top-054px
.top-18px
.top-10512px
.top-216px
.top-20520px
.top-324px
.top-full100%

Top - Example

Second box has no relative positioning
Second box uses .position-relative .top-1

Right

Utility class Value
.right-autoauto
.right-neg-3-24px
.right-neg-205-20px
.right-neg-2-16px
.right-neg-105-12px
.right-neg-1-8px
.right-neg-05-4px
.right-neg-2px-2px
.right-neg-1px-1px
.right-00
.right-1px1px
.right-2px2px
.right-054px
.right-18px
.right-10512px
.right-216px
.right-20520px
.right-324px
.right-full100%

Right - Example

Second box has no relative positioning
Second box uses .position-relative .right-1

Bottom

Utility class Value
.bottom-autoauto
.bottom-neg-3-24px
.bottom-neg-205-20px
.bottom-neg-2-16px
.bottom-neg-105-12px
.bottom-neg-1-8px
.bottom-neg-05-4px
.bottom-neg-2px-2px
.bottom-neg-1px-1px
.bottom-00
.bottom-1px1px
.bottom-2px2px
.bottom-054px
.bottom-18px
.bottom-10512px
.bottom-216px
.bottom-20520px
.bottom-324px
.bottom-full100%

Bottom - Example

Second box has no relative positioning
Second box uses .position-relative .bottom-1

Left

Utility class Value
.left-autoauto
.left-neg-3-24px
.left-neg-205-20px
.left-neg-2-16px
.left-neg-105-12px
.left-neg-1-8px
.left-neg-05-4px
.left-neg-2px-2px
.left-neg-1px-1px
.left-00
.left-1px1px
.left-2px2px
.left-054px
.left-18px
.left-10512px
.left-216px
.left-20520px
.left-324px
.left-full100%

Left - Example

Second box has no relative positioning
Second box uses .position-relative .left-1

Absolute position

The element is removed from the normal document flow and creates no space for itself. It is positioned relative to its nearest "positioned" ancestor (one that is not static); if none exists, it is relative to the initial containing block (usually the body).

Example

Normal flow inside a positioned parent: the child remains in document flow and takes up space.
Absolute child: .position-absolute .top-1 .right-1 is removed from flow and positioned relative to the parent (which has .position-relative).

Fixed position

The element is removed from the normal flow and pinned relative to the browser viewport. It stays in the same place even when the page is scrolled, which is common for navigation bars or "back to top" buttons.

Example

Normal flow: both boxes are in the document flow and scroll with the page.
Fixed element: .position-fixed .top-1 .right-1 is removed from flow and pinned to the viewport — it will remain visible while scrolling.

Sticky position

A hybrid that toggles between relative and fixed based on the user's scroll position. It behaves like a relative element until it reaches a specified threshold (e.g., top: 0), at which point it "sticks" to that position within its parent container while scrolling.

Example

Not sticky: the small header scrolls out of view with the container's content.
Sticky: .position-sticky .top-0 will stick to the container's top edge as you scroll inside the container. When used in the page flow it will stick to the viewport when its container reaches the threshold.

Utility classes

Utility classes may be included in your HTML or applied using Utility classes in your Sass.

Utility Example Code
.position-value .position-absolute class=("position-absolute")
.top-units .top-1 class=("top-1")
.right-units .right-1 class=("right-1")
.bottom-units .bottom-1 class=("bottom-1")
.left-units .left-1 class=("left-1")

  • Use single-quoted strings in Utility classes.
  • Do not quote numbers or px values. With the exception of half (05), values like '105', and '205' should be treated as strings.
  • String tokens for half values (like 05) and negative values (like neg-1) may also be written with their unquoted number token equivalent: 0.5, 1.5, 2.5, -1, -1.5, etc.
  • If multiple utilities share the same prefix (ex: .text- or .flex-) or a single utility accepts multiple kinds of values (ex: .border accepts both border weight and border color), their shared mixin can accept multiple comma-separated values:
    • u-text('primary-darkest', 'no-underline', 'bold')
    • u-border-top(2px, 'accent-warm')
    • Output any utility mixin as !important by appending !important to the mixin’s argument list:
      • u-bg('red-warm-50v', !important)


Utility variants

More information about utility variants can be viewed on the utility variants page. Responsive and state variants are listed as true when they are available for use.

Responsive variants

You can apply different styles at differentresponsive breakpoints using responsive utilities. Use a breakpoint prefix separated with a : to target a utility at a responsive breakpoint and higher (eg. .desktop:border-05).

Utility variable Responsive
$font-style-settings false

State variants

You can apply different styles for different state variants using state utilities. Use a state prefix separated with a : to target a utility for a specific state. (eg. .hover:shadow-2).

Utility variable Active Focus Hover Visited
$font-style-settings false false false false
Looking for U.S. government information and services?
Visit USA.gov