我是 HTML 新手。我看过了
"An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed)."
那么如何找到位置最近的祖先元素呢?
最佳答案
元素对象有一个名为offsetParent
的属性。例如:
document.getElementById("ElementId").offsetParent
关于javascript - 如何在javascript中获取绝对元素的祖先定位元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47887816/