CSS position Property
position property specifies the type of positioning method used for an element (static, relative, absolute, or fixed).
CSS top Property
top property affects the vertical position of a positioned element. This property has no effect on non-positioned elements.
- If position: absolute; or position: fixed; - the
topproperty sets the top edge of an element to a unit above/below the top edge of its nearest positioned ancestor.
- If position: relative; - the
topproperty makes the element's top edge to move above/below its normal position.
Right, bottom, and left properties have similar effects.
CSS z-index Property
z-index property specifies the stack order of an element.
An element with greater stack order is always in front of an element with a lower stack order.
z-index only works on positioned elements (position: absolute, position: relative, position: fixed).