You can determine the location, width, and height of an object by using a combination of the offsetLeft, offsetTop, offsetHeight, and offsetWidth properties. These numeric properties specify the physical coordinates and dimensions of the object relative to the object's offset parent. For more ...
offsetTop和offsetLeft的值在某些特殊的情況下是會使用到的,為了實現(xiàn)值的準(zhǔn)確獲取,本文采用js代碼實現(xiàn)下,有需求的朋友可以參考下哈 代碼如下: function offsetTop( elements ){ var top = elements.offsetTop; var parent = elements.offsetParent; while( parent != null ){ ...