tags:

views:

35

answers:

4

I'm trying to position a div tag on my page absolutely so no matter if you resize the page or not the div does not move position. . I've used absolute positioning in both the div tag and in some JQuery .css({position:absolute}), It still moves when i resize the screen. quite annoying.

A: 

From what I understand from your question, it sounds like you need position: fixed

Position absolute will position the element absolutely within its parent (more or less), and will still move when the page is scrolled.

Position fixed will position the element at the same place within the window, no matter whether you scroll or not.

Show us what you have, because I may have misunderstood your question.

Mailslut
$("#dataBar1").html($("<div><a href='#PP class='P'> " + sw+ "</a></div>")).css({ position: 'static', left: (sDate1.left) + "px", top: (sDate1.top + topPos) + "px", width: (eDate1.left - sDate1.left) + 25 + "px" }).addClass("option1");I tried static and it keeps it in a position, however not the postion based on my properties
Calibre2010
Add that to your question ;) by editing it.
Zwik
Sorry, I meant 'fixed' not 'static'
Mailslut
A: 

CSS:

position: fixed
graphicdivine
+1  A: 

You want to use position: fixed however that is not supported by IE 6 and lower so you have to apply some tricks to make position: fixed work in IE;

Dave Anderson
@graphicdivine thanks for the clarifying edit, nearly have the rep to help that way myself!
Dave Anderson
A: 

Calibre2010, it seems to me that in order to have the position be correlated on your properties (BTW which?) you have to recalculate and set them when the related expression changes:

-> For example, an expression: width: (eDate1.left - sDate1.left)

-> Do eDate1.left and/or sDate1.left change over time?

If so, maybe you would want do apply this constraint again and again, when this values change. In this case you would need to intercept them and then apply your "rules".

Is this this your case? Does it make sense to you?

Dario Cangialosi