EDIT: this is approximately absolute position
Very old findPos function
http://www.quirksmode.org/js/findpos.html
Scrolling and Border Option
function getPosition(el){ var x=0,y= 0; while(el) { x+=(el.offsetLeft-el.scrollLeft+el.clientLeft); y+=(el.offsetTop-el.scrollTop+el.clientTop); el=el.offsetParent; } return{x:x,y:y} }
to get right
var info=getPosition(element); console.log('marginRight: 'info.x-element.offsetWidth);
Note1 : these are javascript functions compatible with older browsers. this is why jQuery is not needed. Obviously, performance is much better than using jQuery.
Note2 : there are many other versions if you are looking for a search position
getBoundingClientRect
to get right
var info=element.getBoundingClientRect(); // Native Javascript ..think 1.6+ console.log('marginRight: 'info.right-info.width);
Conclusion
There is no easy way to get dimensions, offsets, apply a CSS element if you want to use all compatible scripts.
The getPosition function is probably the best function (considering compatibility) that makes it easy to calculate these values.
Note: since there is a while loop inside the function, on very old machines you may get some problems with nested nested elements.
if you use html5 and css than for getBoundingClientRect
Note: maybe both will work when converting css3.
EDIT
I need values equivalent to the .css ('right') values that Firefox returns
To get these values, you first need to find the position of the element.
So: getPosition function or getBoundingClientRect
then you need to calculate the values of top / bottom, left / right.
left=x right=x-width top=y bottom=y-height
EDIT2:
To apply this only to the parent element, you need to do getPosition also in the parent element
and the calculations are shown in @kalley's answer.