Positioning in CSS
Positioning Elements
The CSS positioning properties allow us to position an element. It can also place one element behind another. Elements can be positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first. They also work differently depending on the positioning method.
Syntax:-
Its syntax is:-
< style >
element{
position: static| absolute| fixed| relative| sticky| initial| inherit;
}
< /style >
Further Explanation:-
Value | Description |
---|---|
static | Elements render in order in the document flow. |
absolute | The element is positioned relative to its first-positioned ancestor element. |
fixed | The element is positioned relative to the browser window. |
relative | The element is positioned relative to its normal position. |
sticky | The element is positioned based on the user scroll position. |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |