Class | Properties |
---|---|
.static | position: static; |
.relative | position: relative; |
.absolute | position: absolute; |
.absolute-top | @include absolute-top(); |
.absolute-center | @include absolute-top(); |
.fixed | position: fixed; |
.fixed-top | @include fixed-top(); |
.fixed-bottom | @include fixed-bottom(); |
.sticky | position: sticky; |
.sticky-top | @include sticky-top(); |
.initial | position: initial; |
Usage
Static
Use .static
to position an element according to the normal flow of the document.
Any offsets will be ignored and the element will not act as a position reference for absolutely positioned children.
Relative
Use .relative
to position an element according to the normal flow of the document.
Offsets are calculated relative to the element’s normal position and the element will act as a position reference for absolutely positioned children.
Absolute
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.
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.
Fixed
Use .fixed
to position an element relative to the browser window.
Offsets are calculated relative to the viewport and the element will act as a position reference for absolutely positioned children.
Sticky
Use .sticky
to position an element as relative until it crosses a specified threshold, then treat it as fixed until its parent is off screen. Offsets are calculated relative to the element’s normal position and the element will act as a position reference for absolutely positioned children.
Sticky positioning is not supported in IE11
Variants
By default, only responsive variants are generated for position utilities.
Responsive
To control the position of an element at a specific breakpoint, add a {screen}:
prefix to any existing position utility.
For example, use .md:fixed
to apply the fixed
utility at only medium screen sizes and above.
Hover-state
To include hover-state variants like .hover:fixed
, add "position"
to the $hover-variants
variable when recompiling your CSS:
$hover-variants: (
// ...
"position",
);