Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
bottom ist top + height
right ist left + width
body {
margin: 0px;
}
#box {
background: #000;
position: absolute;
bottom: -50px;
width: 300px;
height: 50px;
}
function move(objID) {
var obj = document.getElementById(objID);
alert( parseInt(obj.style.bottom) );
}
Nö woher denn das geht ja nicht.1. antwort erledigt worden sein?!
ok, dann halt nur per js, man kommt über style eben nicht immer an die werte ran. deswegen geht man ja auch über offsetTop/Left.Und wie?
css:
...
Kommt NaN zurück.
aber sicher, warum soll das nicht gehen?Nö woher denn das geht ja nicht.
aber sicher, warum soll das nicht gehen?
<html>
<head>
<title>test</title>
</head>
<body>
<div style="position:absolute;left:10px;width:10px;top:100px;height:100px"><div id="box" style="position:relative;left:10px;width:10px;top:100px;height:100px">xxx</div></div>
<script type="text/javascript">
function getX(obj)
{
var nX;
var object;
nX = 0;
object = obj;
while (object.offsetParent != null)
{
nX += object.offsetLeft;
object = object.offsetParent;
}
nX += object.offsetLeft;
return nX;
}
function getY(obj)
{
var nY;
var object;
nY = 0;
object = obj;
while (object.offsetParent != null)
{
nY += object.offsetTop;
object = object.offsetParent;
}
nY += object.offsetTop;
return nY;
}
function test()
{
var box = document.getElementById("box");
alert("rel. L: " + box.offsetLeft + " - rel. R: " + (box.offsetLeft + box.offsetWidth));
alert("rel. T: " + box.offsetTop + " - rel. B: " + (box.offsetTop + box.offsetHeight));
alert("abs. L: " + getX(box) + " - abs. R: " + (getX(box) + box.offsetWidth));
alert("abs. T: " + getY(box) + " - abs. B: " + (getY(box) + box.offsetHeight));
}
window.onload = test;
</script>
</body>
</html>
jetzt verstehe ich dich auch nicht. da steht nicht immer ein wert, sondern nur, wenn du diesen mit js setzt (ich dachte zwar auch noch, wenn dieser über css gesetzt wird, dem ist aber - seiner aussage nach - nicht so, dass glaube ich jetzt aber erst mal, bzw. ist es auch egal, weil nicht immer ein wert dort steht und man deswegen diesen nicht verwenden kann)Mann BlueFox: Bist du nie auf die Idee gekommen dir mal NODE.style.bottom ausgeben zu lassen?
???Und du hättest auch sagen können, dass das DIV direkt im body liegt - dann musst du natürlich anstatt node.parentNode, document.documentElement nehmen.