Positioning
Positioning
The default positioning mode in CSS is position: static. In static positioning properties top, right,
bottom and left do no affect the position of the element.
Relative positioning is pretty much the same as static, but properties top ,right, etc displace the
element relative to its normal position in the flow of the document.
Static positioning
Default. The element is positioned according to the Normal Flow of the document. top, right,
bottom, left and z-index have no effect.
Relative positioning
The element is positioned according to the normal flow of the document, and then offset relative
to itself based on the values top, right, bottom and left.
This value creates a new 'stacking context' when the value of z-index is not auto.
Absolute positioning
Allows you to position something at an exact point on the screen without disturbing the other
elements around it.
Using absolute positioning on an element will remove that element from the normal document
flow while being positioned relative to an ancestor element.
Using absolute positioning allows you to position elements anywhere on the screen using top,
right, bottom, and left properties.
This property is really usefull when you want to position something at an exact point on the
screen, without disturbing any of the other elements.
modals
images with a caption on it
icons on top of other elements
Absolute positioning has very specific use cases. If posibble, using flexbox or grid should be
priorirized. Absolute positioning shouldnt be used to do entire page layouts
if !static, absolute positioning will use that element as his parent. You can use then top, left, etc.
The margins of absolutely positioned boxes do not collapses with other margins, because
creates a new stacking context.
Is specially useful for things like navigation bars and floating chat buttons.
Sticky positioning
They act like normal elements until you scroll past them, then they start behaving like fixed
elements. Dont taken out of the normal flow of the document.
Ensure that elements positioned with an absolute or fixed value do not obscure other content
when the page is zoomed to increase text size.