Why is container "relative" and box "absolute" and not vice versa? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why is container "relative" and box "absolute" and not vice versa?

JS lesson: DOM & events > Animation: I don't understand the positioning here. Shouldn't the green container have an absolute position on the page and the red box be relative to the container? Why is it the other way around? Can someone explain?

21st Jan 2017, 5:50 PM
Pete Wright
Pete Wright - avatar
3 Answers
+ 3
Both can be relative or absolute , it doesn't matter. red box always stay inside the green container
4th Feb 2017, 2:09 PM
Lavish Thomas
Lavish Thomas - avatar
0
Always take relative position on the parent or man term
7th Feb 2017, 3:48 AM
Sunil Parmar
0
I quote Lavish, don't know why the lesson specifies that as requirement
20th Mar 2017, 10:08 PM
Alessandro Domanico
Alessandro Domanico - avatar