| <html> |
| <head> |
| |
| <body style='margin:8px'> |
| <div> |
| <div style="position: absolute; width: 150px; height: 150px; border: 5px solid green;"> |
| <div style="position: relative; width: 50px; height: 50px; border:13px solid blue; padding:12px;margin:10px"> |
| <div id='x' style="border:2px solid red"> |
| jee |
| </div> |
| </div> |
| </div> |
| <script> |
| var el = document.getElementById('x'); |
| while (el) { |
| document.write('<br>-------------------------------------------------offsetLeft:'+el.offsetLeft); |
| el = el.offsetParent; |
| } |
| el = document.getElementById('x'); |
| while (el) { |
| document.write('<br>-------------------------------------------------offsetTop:'+el.offsetTop); |
| el = el.offsetParent; |
| } |
| </script> |