Javascript 中未更新style.right和.style.top选项
我有两张照片,一张是轮子,另一张是箭头。我想确定箭头的位置,使其指向方向盘 在我的身体部位,我定义:Javascript 中未更新style.right和.style.top选项,javascript,html,css,Javascript,Html,Css,我有两张照片,一张是轮子,另一张是箭头。我想确定箭头的位置,使其指向方向盘 在我的身体部位,我定义: <body onload="g1()"> <img src="arrow.png" id="arrow" width=8%> <br> <center> <img src="wheel.png" id="wheel"> <br> <h2 style="width:200p
<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>
现在的问题是,当.style.right和.style.top的值被更新时,箭头的位置没有被更新。(我发现它们是通过在中间插入警报来更新的)
我是不是遗漏了什么?作为记录,我在Chrome和IE中都试过了,但箭头仍然不动
(附:上传图片至)
编辑:
附加CSS脚本:
<style type="text/css">
body{
//font-size:22px;
}
#arrow{
position:absolute;
bottom:100px;
right:500px;
}
</script>
身体{
//字体大小:22px;
}
#箭{
位置:绝对位置;
底部:100px;
右:500px;
}
屏幕宽度/2
将为您提供一个数字,而不是CSS长度。您需要向其添加“px”
。它们是否已定位,如位置:绝对的|相对的|另一个
@Musa绝对的,现在已附加css。完成,但仍然没有更改任何内容。。。var left1=屏幕宽度/2+“px”;你是否定义了屏幕
?奇怪的是,它似乎获得了屏幕的应有宽度,设置了箭头的正确位置,但实际上没有移动它。
<style type="text/css">
body{
//font-size:22px;
}
#arrow{
position:absolute;
bottom:100px;
right:500px;
}
</script>