我已经用 javascript 完成了这段代码来尝试我的第一个 javascript 动画,但是当我打开页面时,它显示了一个空白页面...
谁能告诉我代码有什么问题以及为什么它没有显示任何内容?
提前致谢...
<html>
<head>
<title>Trying js Animation</title>
</head>
<body>
<style>
#container{
width: 500px;
height: 500px;
color: green;
position: relative;
}
#box{
width: 50px;
height: 50px;
color: red;
position: absolute;
}
</style>
<div id="container">
<div id="box">
</div>
</div>
<script type="text/javascript">
var t = setInterval(move, 1);
var pos = 0;
var box = document.getElementById('box');
function move(){
pos += 1;
box.style.left = pos + "px";
}
</script>
</body>
</html>
最佳答案
盒子是白色的。将“颜色”更改为“背景颜色”。
关于javascript动画不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39666063/