我只想说我在页面上移动表格时遇到问题,就像使用图像一样。然而,这是有问题的。我已经知道如何使用坐标或使用方程式在圆圈中移动图像。我尝试对此应用坐标方式,但是,即使表格正确显示和隐藏,表格也不会移动。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 78px;
height: 63px;
}
.auto-style3 {
width: 55px;
height: 54px;
}
</style>
</head>
<body style="width: 235px">
<script>
function moveTable() {
if (playing == false) {
myTimer = window.setTimeout(move, 25);
playing = true;
}
}
leftCoor = new Array(10, 30, 50, 70, 90, 110, 130, 110, 90, 70, 50, 30);
var myTimer;
var playing = false;
var index = 0; //was undefined
function move() {
//if (playing == false) {
var tplayer = document.getElementById("tblFormat");
tplayer.style.visibility = "visible";
tplayer.style.left = leftCoor[index] + "px";
index++;
if (index > 11) index = 0;
//myTimer = window.setTimeout(move, 100); //corrected
//playing = false;
//}
}
function CloseTable() {
var tplayer = document.getElementById("tblFormat");
tplayer.style.visibility = "hidden";
tplayer.style.left = "10px";
window.clearTimeout(myTimer);
playing = false;
}
</script>
<table class="auto-style1" style="background-color: #FF0000; border: thick inset #0000FF; visibility: hidden; left: 10px;" id="tblFormat">
<tr>
<td style="text-align: right">
<img id="imgClose" alt="" class="auto-style2" src="images/emyller_close_button.png" onclick="CloseTable()" /></td>
</tr>
<tr>
<td>Hello World,<br />
Please hit the close button to close this table.</td>
</tr>
</table>
<p>
</p>
<p>
<img id="imgOpen" alt="" class="auto-style3" src="images/start-button.png" onmouseover="move()" /></p>
</body>
</html>
感谢所有帮助!
更新代码
由于答案的想法而更新了代码。还是一样的问题,还是不动。
更新的代码和编辑#2
好的,所以它有点移动,但不是我想要的方式。我希望它是连续的,并且只在鼠标悬停时激活(如果有意义的话)。现在,我必须进行多次鼠标悬停才能使其移动。