Jerome
03-10-2004, 01:22 PM
Hi,
I like to move an absolute positioned div --relative with respect to the body width-- horizontaly, without losing the relative respect to the body width.
Moving --mydiv-- works well, the problem I experience however, seems to be getting the correct left values (see point 1) and saving the new values (see point 2)
#mydiv{
position:absolute;
left:20%;
}
1.
Getting the current distance with:
document.getElementById('mydiv').style.left
or:
document.getElementById('mydiv').currentStyle.left
always gives the value in px, even if the stylesheet declaration is in percentage e.g. 20% can give 130px.
2.
The --mydiv-- is moved to another place, time to save the new left distance:
posibility A.
document.getElementById('mydiv').style.left=the new value+"%";
works perfect the first time the --mydiv-- is moved but the second time when getting the current distance (see point 1) the current distance f.e. 10% isn't 65px but 10px???
Posibility B.
document.getElementById('mydiv').style.setExpression("left",distancevalue);
Doesn't except percentages as value??
Thanks for Your time and help,
Jerome
I like to move an absolute positioned div --relative with respect to the body width-- horizontaly, without losing the relative respect to the body width.
Moving --mydiv-- works well, the problem I experience however, seems to be getting the correct left values (see point 1) and saving the new values (see point 2)
#mydiv{
position:absolute;
left:20%;
}
1.
Getting the current distance with:
document.getElementById('mydiv').style.left
or:
document.getElementById('mydiv').currentStyle.left
always gives the value in px, even if the stylesheet declaration is in percentage e.g. 20% can give 130px.
2.
The --mydiv-- is moved to another place, time to save the new left distance:
posibility A.
document.getElementById('mydiv').style.left=the new value+"%";
works perfect the first time the --mydiv-- is moved but the second time when getting the current distance (see point 1) the current distance f.e. 10% isn't 65px but 10px???
Posibility B.
document.getElementById('mydiv').style.setExpression("left",distancevalue);
Doesn't except percentages as value??
Thanks for Your time and help,
Jerome