[英]style.right and .style.top options not updated in
我有兩張照片,一個是輪子,另一個是箭頭。 我想定位箭頭,使其向下指向方向盤。
在我的身體部位,我定義了:
<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中都嘗試過,但箭頭仍然沒有動。
(ps。將圖片上傳到這里 )
編輯:附加CSS腳本:
<style type="text/css">
body{
//font-size:22px;
}
#arrow{
position:absolute;
bottom:100px;
right:500px;
}
</script>
screen.width/2;
會給你一個數字,而不是CSS長度。 您需要添加"px"
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.