6

I have a div{position:absolute}. From w3cschools:

absolute - The element is positioned relative to its first positioned (not static) ancestor element

Is there an easy way with browser inspector(Chrome, Firebug) to get the first not static ancestor, to which my div was positioned relatively?

Islam Sabyrgaliyev
  • 340
  • 1
  • 5
  • 10

1 Answers1

8

Works in Chrome, Safari, and Firefox:

  1. Right-click the <div> and choose 'Inspect Element'.
  2. In the inspector choose the "Console" tab and type in $0.offsetParent. Press enter.
  3. The result is the offset parent of your selected element.

Bonus: In Chrome and Safari, If you right-click the result in the console you can reveal it in the elements panel.

oztune
  • 325
  • 3
  • 8