DHTML Lab - DHTML Diner - Element Page Coordinates, Part 4 | 3
Determining Element Page Coordinates, Part 4
|
Behind the scenes, the code looks something like this:
BlueSquareReference.style.left = DL_GetElementLeft(RedSquareReference) + "px";
BlueSquareReference.style.top = DL_GetElementTop(RedSquareReference) + "px";
All of the examples in this article follow the same guidelines.
Now, position the blue square by clicking on the large button.
The red square is nested in a simple paragraph element with a 5-pixel border. <P STYLE="border:5px green solid; padding:10px;"> <IMG ID="redbox" SRC="redbox.gif" WIDTH="200" HEIGHT="200"> </P> |
Result
Our position calculations are correct in both directions. The border width of the containing element (<P>) does not affect the calculations because the element is not in the element offset hierarchy (see Part 1 for discussion of element hierarchies.) |
But even a static element can be made part of the element hierarchy.
Produced by Peter Belesis and
All Rights Reserved. Legal Notices.Created: Nov 21, 2002
Revised: Nov 21, 2002
URL: https://www.webreference.com/dhtml/diner/realpos4/3.html