CSS Position
The position property specifies the type of positioning method used for an element (static, relative, fixed, absolute or sticky).
CSS Position Property
The position property specifies the type of positioning method used for an element.
There are five different position values:
staticrelativefixedabsolutesticky
Example 1: position: static;
HTML elements are positioned static by default. Static positioned elements are not affected by the top, bottom, left, and right properties.
Example 2: position: relative;
An element with position: relative; is positioned relative to its normal position.
Example 3: position: absolute;
An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
Example 4: position: fixed;
An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled.
Example 5: position: sticky;
An element with position: sticky; is positioned based on the user's scroll position.
Scroll down to see the sticky effect.
Scroll...
Scroll...