Como posso fazer para que esse objeto mova-se para cima? (detalhes)
Tenho um pequeno código que faz com que uma imagem se mova quando botões são acionados... Mas o problema, ela está movendo para baixo e para a esquerda da tela, como posso fazer para que a imagem suba? Tentei usar "bottom" em vez de "top" e "left" mas não funcionou.
Aqui está o código(Top = desce a imagem)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
#imagemNome{
position: relative;
}
</style>
<script language="JavaScript" type="text/javascript">
i = 0;
function Seguir() {
i = i + 2;
document.getElementById("imagemNome").style.left = i;
if (i <= 1000) {
window.setTimeout ("Seguir()", 100);
}
}
function MoverParaBaixo() {
i = i + 5;
document.getElementById("imagemNome").style.top = i;
if (i <= 1000) {
window.setTimeout ("Seguir()", 100);
}
}
function MoverParaCima() {
i = i + 5;
document.getElementById("imagemNome").style.bottom = i;
if (i <= 1000) {
window.setTimeout ("Seguir()", 100);
}
}
</script>
</head>
<body >
<center>
<table>
<tr>
<td><input type="button" value="→" onclick="Seguir()"></td>
<td><input type="button" value="↓" onclick="MoverParaBaixo()"></td>
<td><input type="button" value="↑" onclick="MoverParaCima()"></td>
</table>
</center>
<img src="passaro.gif" id="imagemNome">
</body>
</html>Discussão (3)
Carregando comentários...