Positioning
suggest changeSyntax
- position: static|absolute|fixed|relative|sticky|initial|inherit|unset;
- z-index: auto|number|initial|inherit;
Parameters
Parameter | Details |
—— | —— |
static | Default value. Elements render in order, as they appear in the document flow. The top, right, bottom, left and z-index properties do not apply. |
relative | The element is offset from where it would have been in normal flow. left: 20px moves it 20px to the right, and the original space is kept. |
fixed | The element is positioned relative to the viewport, unless an ancestor such as one with transform or filter becomes the containing block. |
absolute | The element is positioned relative to its nearest positioned (not static) ancestor, or the initial containing block. |
initial | Sets this property to its default value.|
inherit | Inherits this property from its parent element.|
sticky | The element is in normal flow until the given offset would scroll it out of the sticky constraint rectangle, then it is held there. It is not the same as fixed: it stays inside its containing block and the nearest scrollport. |
unset | Combination of initial and inherit. More info here. |
Remarks
Normal Flow is the flow of elements if the position of element is static.
- defining width is beneficial because in some cases it prevents overlapping of element’s content.