position
Controls how an element is placed relative to the page’s normal flow. Together with top, right, bottom, left and z-index, it lets you overlap elements or pin them on screen.
- static (default): the element follows the normal flow and ignores top, right, bottom, left and z-index.
- relative: keeps its space in the flow and is offset from its original position.
- absolute: leaves the flow and is placed relative to its nearest positioned ancestor.
- fixed: leaves the flow and is placed relative to the viewport; it does not move on scroll.
- sticky: behaves as relative until it reaches the given threshold, then sticks inside its container.
- inset: shorthand to write top, right, bottom and left in a single property.
Example
Child 2 has the item class. Change position and scroll inside the container to see how each value reacts. Notice how the other children take its space when it leaves the flow.
ResultLive
html
css