Hi,
I'm writing a script where I want to overlay an element on an
existing element in the DOM.
E.g. an image on the page, and I want to overlay a 50% transparent
black box on it. So I pass the element or id to the function that
does this.
The function uses MochiKit.Style.getElementPosition and
MochiKit.Style.getElementDimensions to determine position and size of
the source element and then creates an absolute positioned div above it.
In my tests this worked fine, regardless of how I positioned the
input image, though the test page was just a simple one, with static
objects.
Now I'm working on incorporating this into a page, where the source
elements are nested into more complex structure with surrounding
elements also being styled.
What happens is that MochiKit.Style.getElementPosition(srcelem)
doesn't return the proper coordinates.
Here's what's in the css:
body {
position: relative;
margin: 0 auto;
}
#container {
position: relative;
background-color: white;
width: 840px;
margin: 0 auto;
margin-top: 7px;
}
The container is right inside the body tag and everything else is
nested within it.
If I call MochiKit.Style.getElementPosition(srcelem), I get
coordinates that are offset by the amount that #container is offset
within <body>.
If I call MochiKit.Style.getElementPosition(srcelem, $
('container')) , I get the correct coordinates.
The question is 'why'. The CSS isn't mine, and I see a bit of
weirdness in it. I'll see about changing that around. But what I'd
like to understand is why the results are different. This might well
be a CSS question rather than MochiKit or JS. I'm hoping someone here
has experience with this and can turn on the light for me.
Thanks much.
Juergen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---