Reputation: 93
I am new to HTML. I have read that
"An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed)."
So how to find that nearest positioned ancestor element?
Upvotes: 3
Views: 225
Reputation: 93
There is a property called offsetParent
for element object. ex:
document.getElementById("ElementId").offsetParent
Upvotes: 5