For instance, I have a div, with a margin of, say, 20%, and I want to find the distance between [the left side of] it and [the left side of] the body. Is there a way of doing this that supports all major browsers and is guaranteed to work for at least the latest versions (eg. ie 7+, safari 3+, firefox (whatever they're up to now)+, etc.), and is possibly contained inside of other elements?
<!DOCTYPE html>
<html>
<head>
<!--stuff that goes here-->
</head>
<body>
<div id="outer">
<div id="calculateDistance">et cetera
</div>
</div>
</body>
</html>
and the css
#outer{
margin:10%;
padding:5%;
border:1px solid #000000;
}
#calculateDistance{
margin:20%
border:3em solid #000000;
}