【发布时间】:2009-08-24 12:54:15
【问题描述】:
这里有一些代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style>
body { margin:0; padding:0; }
#a {
position:absolute;
background:#0FF;
left:0;
height:300px;
width:120px;
}
input, #a {
margin:10px;
}
</style>
<script>
function foo() {
box = document.getElementById('a');
var computedStyle = box.currentStyle || window.getComputedStyle(box, null);
box.style.left = parseInt(computedStyle.left) + 10 + 'px';
setTimeout("foo()",20);
}
</script>
</head>
<body>
<input type="button" value="RUN, FORREST, RUN!" onClick="setTimeout('foo()',20)">
<div id="a"></div>
</body>
</html>
如您所见,它在页面上对 DIV 进行了动画处理,但动画并不清晰流畅—— DIV 的边框实际上发生了变形。 有人知道我怎样才能让它正常工作吗?
【问题讨论】:
-
您能否定义“变形”...它在我的机器上的行为符合预期。
-
在 3D 游戏中看起来像“VSync 已关闭”
标签: javascript animation