Why do we need to make positioning of a parent of an element "relative" if we want to position that element "absolute"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why do we need to make positioning of a parent of an element "relative" if we want to position that element "absolute"?

Positioning

24th Aug 2021, 7:46 PM
Barabbas
Barabbas - avatar
3 Answers
+ 1
Because relative will mark the boundary point for absolute element . If you will do absolute without making parent relative then the absolute element will look for a relatively or positioned element above his parent element and position itself relative to it , if there is no such element then it will position itself relative to body element.
24th Aug 2021, 8:45 PM
Abhay
Abhay - avatar
+ 1
Abhay thank you for the explanation 💯👍🏽 it's starting to make sense
25th Aug 2021, 2:51 PM
Barabbas
Barabbas - avatar
0
Barabbas correction at line 6 ,i meant relatively or absolutely* positioned
25th Aug 2021, 2:53 PM
Abhay
Abhay - avatar