Which position are you comfortable? and how do they differ?
.
.
.
.
.
.
Question: How absolute, relative, fixed and static position differ?
Answer:
🔥absolute : it place an element exactly where you want to place it. absolute position is actually set relative to the element's parent. if no parent available then relatively place to the page itself.
🔥relative, is position an element relative to itself (from where the element would be placed, if u don't apply relative positioning). for example, if u set position relative to an element and set top: 10px, it will move 10px down from where it would be normally.
🔥fixed, element is positioned relative to viewport or the browser window itself. viewport doesn't changed if u scroll and hence fixed element will stay right in the same position.
🔥static, element will be positioned based on the normal flow of the document. usually, u will use position static to remove other position might be applied to an element
Z index only works on positioned elements (absolute, relative, or fixed)
Top comments (1)
read and play with css position
frontendchef.com/blog/learn-positi...