+ 1
Difference between absolute and relative positioning ? [Unsolved]
In the following code even if i change cont element to have absolute positioning nothing is changing or even if you put the opposite values of position on child and parent , still nothing will change! https://code.sololearn.com/WzsOBPc2Xybw/?ref=app
6 Answers
+ 3
Run the code to get understand of css positioning
https://code.sololearn.com/WNrAqPm0nhW9/?ref=app
+ 2
Hey dear Abhay check this out:.https://dzone.com/articles/css-position-relative-vs-position-absolute.
+ 1
1. Body the very first element.
and div in default displayed as block, which means in default gets all the parents area if other is not written like: width: 20% or height 30px etc.
2. As you determine the width and height of all div elements... they will get exectly those parameters.
3. When you give position: absolute. It take place not relative to body. But relative to parent element.
But as far as the sizes of two divs are equal child element had to go out of the parent's territory
0
relative position element relatively to its initial position
absolute position element relatively to initial position of first positionned parent
0
visph ty for answering but i still don't understand what you mean by first positioned parent.An example would be much appreciated .
Anyway i will try to look more into this myself, i have gone through many articles but nothing makes sense to me yet .
0
first positioned parent means nearest parent with css 'position' property set to anything but static ^^
if no such parent, root element is used (html/body)