CSS offset-position
The CSS offset-position
property specifies the positioning of an element relative to its normal position in the document flow. This property is used to offset an element from its normal position while still preserving the space it would have occupied in the document flow.
The offset-position
property can take one of the following values:
auto
: The element is positioned according to the normal document flow.absolute
: The element is removed from the normal document flow and positioned relative to its nearest positioned ancestor.fixed
: The element is positioned relative to the viewport and does not move when the page is scrolled.relative
: The element is positioned relative to its normal position in the document flow.static
: The element is positioned according to the normal document flow.sticky
: The element is treated as relatively positioned until it crosses a specified threshold, at which point it becomes fixed.
Let's see some examples of how the offset-position
property works:
In this example, the element is offset from its normal position using the offset-position: relative;
property. The top: 20px;
and left: 50px;
properties specify the offset values for the element.
In this example, the element is removed from the normal document flow and positioned relative to its nearest positioned ancestor using the offset-position: absolute;
property.
Experiment with different values for the offset-position
property to see how it affects the positioning of elements on your webpage.