offsetLeft, offsetTop, offsetParent property

這3者要一起看,

offsetLeft定義:

returns the left position (in pixels) relative to the left side the offsetParent element.

Element offsetLeft Property:
http://www.w3schools.com/jsref/prop_element_offsetleft.asp


offsetTop定義:

returns the top position (in pixels) relative to the top of the offsetParent element.

Element offsetTop Property:
http://www.w3schools.com/jsref/prop_element_offsettop.asp


offsetParent定義:


The offsetParent property returns the nearest ancestor that has a position other than static.

Element offsetParent Property:
http://www.w3schools.com/jsref/prop_element_offsetparent.asp



最後, 這篇有詳細的圖解介紹offser系列的東西:

圖解offsetLeft、offsetTop、offsetWidth和offsetHeight
http://emn178.pixnet.net/blog/post/95297028-%E5%9C%96%E8%A7%A3offsetleft%E3%80%81offsettop%E3%80%81offsetwidth%E5%92%8Coffsetheight



留言

熱門文章