When do we use 'position:relative' in a div, does it mean that the elements inside it will have a relative positioning or his own position will be relative to his parent?
Asked
Active
Viewed 88 times
-1
-
1Check out this article: http://alistapart.com/article/css-positioning-101 – Matthew Blancarte Jun 12 '13 at 19:00
-
I wanted to VTC as "general reference", but sometimes you just have to go with the flow. – Mr Lister Jun 12 '13 at 19:15
2 Answers
0
It means that the div is positioned relative to its containing element.
user229044
- 232,980
- 40
- 330
- 338
0
It means its own position will be relative to is closest positioned parent ("positioned" meaning any value for position other than static, or blank).
Absolutely relative positioned elements behave very similar, their position is also relative to the closest positioned parent. The difference is:
position: absolute: the element is taken "out of the flow" when the layout is processed, so other elements behave as if the absolute element didn't exist.position: relative: the element is kept "in the flow" when the layout is processed, and other elements behave as if it hasposition: static.
bfavaretto
- 71,580
- 16
- 111
- 150