我有两张照片,一张是轮子,另一张是箭头。我想把箭头放在适当的位置,使它指向轮子上。
在我的身体部位,我定义:
<body onload="g1()">
<img src="arrow.png" id="arrow" width=8%>
<br>
<center>
<img src="wheel.png" id="wheel">
<br>
<h2 style="width:200px;" id="status"></h2>
</center>
</body>
我的功能是:
function g1()
{
var left1=screen.width/2;
var tikli=document.getElementById("arrow");
//tikli.style.right=0;
//tikli.style.top=0;
tikli.style.right=left1;
tikli.style.top=left1;
tikli.style.zIndex+=2;
//rotateAnimation("wheel",8,710);
}
现在的问题是,当.style.right和.style.top的值正在更新时,箭头的位置却没有。(我发现它们是通过在两者之间插入警报来更新的)。
我是不是遗漏了什么?为了记录在案,我在Chrome和IE中都尝试过,但箭头仍然没有移动。
(附言上传图片到这里)
编辑:附加CSS脚本:
<style type="text/css">
body{
//font-size:22px;
}
#arrow{
position:absolute;
bottom:100px;
right:500px;
}
</script>
screen.width/2;
将给您一个数字,而不是CSS长度。您需要将"px"
添加到其中。