Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Css Sibling Absolute Positioning

Tags:

css

position

Is there any way to absolutely position a div relatively to its sibling? For example: Inside a div there are two other divs - div1 and div2. I want to absolutely position div2 relatively to div1.

like image 455
Arg Geo Avatar asked May 16 '12 18:05

Arg Geo


1 Answers

Absolute positioning is dependent on the "current positioning context", which may include a parent element (if absolutely or relatively positioned) but will never include a sibling element.

Can you reorganize your dom so that you have a parent-child instead of siblings? If so, you could set the parent's position to relative or absolute and the child's position to absolute and the child's position would remain absolute in relation to the parent.

like image 71
Farray Avatar answered Sep 17 '22 22:09

Farray