right position of Div tag

J

John Giblin

I am using the createElement to create a div tag, which contains. I
also use a div as a placeholder so I know where to move the new
created tag. The problem that I am having is to getting the position
of the right side of the div tag.

Does anyone know how to get the position of the right side of an
element.

John
 
P

Paul Wellner Bou

Hi John,

I read some day something about a very strange method to
get the position of elements of a HTML Document even if the
elements aren't postioned absolutely, but I don't remember
and I never used it. Anyway, it only worked in IE, if I remember
it well.

Answering your question...
Does the div, you mentioned, has an absolute position?
You place it with

[HTMLDivElement].style.left = "10px";

(or any other value) at the place you want it to appear?

If you want to do it relative to the right margin, why don't you
use ...style.right instead?

If you can't use that, it will be difficult to get the right value,
if the width of this element isn't fixed.
But you can fix the width of the div by css (or JavaScript setting
the CSS Property). Then the right value is width+left.

In Addition you can use overflow: hidden or overflow: auto to
avoid that the width of the div changes if there is some content
like images that forces the div to increase its width automatically.

Hope I helped you.

Saludo
Paul.
 
J

John Giblin

Paul, thanks for your answer. I really didnt give you the full
picture. The thing that I am trying to do is overlay events in a
calendar. Since some events are one day and other are more, I would
need both the left and right positions. So, now a div element can be
overlayed either 1 or many td's.I am not sure if this is posible since
I have other concerns of resizing the page.


thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top