Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding out CSS positioning with JavaScript

Status
Not open for further replies.

Uttridge

Programmer
Nov 3, 2004
2
GB
Hi!

so using JavaScript I can position an element on the screen


document.getElementById("item1").style.left = 100


and if I want to get the location of item1 then that's easy,


item1location = document.getElementById("item1").style.left


but how about if I want to position something on the screen, relative to another item, where the other item is just in the flow of the document. (ie. doesn't have it's position set)

any ideas?

I'm sure it's possible as I'm sure I've seen flyout menus that allow you to resize the text.

cheers!

 
Relative to another item in the document flow - use margin and padding.

Or maybe I missed something... menus are usually done with absolutely positioned DIV containers and z-index property... to get initial coordinates, use DOM/DHTML properties like offsetHeight/offsetWidth.
 
sorry my fault. Yes it's a menu thing.

Can someone post an example of the offsetHeight thing.

That sounds like the right sort of path to take.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top