使用jQuery获取div的绝对或相对位置位置 [英] using jQuery to get absolute or relative position position of a div
本文介绍了使用jQuery获取div的绝对或相对位置位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我会试着解释我想要得到什么。我有一个div位置:固定(在页面的底部)到该div,还有一些其他的div。我想要的是显示另一个div(绝对位置)与这些div对齐......换句话说,我不想知道div的左边位置......
解决方案
相对于文档: ID')。offset()。left
相对于其父抵消:
$('#ID')。position()。left
I'll try to explain what i'm trying to get. I've a div with position:fixed (at the bottom of a page) into that div, there is some other divs. What i want is to show another div (with absolute position) aligned to the right with those divs... in other words, i wan't to know the left position of the divs...
解决方案
Relative to the document:
$('#ID').offset().left
Relative to its offset parent:
$('#ID').position().left
这篇关于使用jQuery获取div的绝对或相对位置位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文