Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我无法更改 html,我有 2 个未嵌套的 div,并且我想将 div1 相对于 div2 定位,因为它们是嵌套的。有解决方案吗?
var top = $('#firstElement').offset().top(); var left = $('#firstElement').offset().left(); top += relativeY; left += relativeX; $('#secondElement').css({'top': top; 'left': left});