在使用弹性运动时,需要注意一些小问题,即运动的元素所要改变的属性值不能太小,如果太小在反弹时就会出现负值,导致出现错误,所以要给出一定的限制,下面写一个小Demo,欢迎大家复制粘贴及吐槽。
先来看一下效果图:
以下是代码实现:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>原生JS实现弹性运动中需要注意的问题</title>
<style>
#box {
width: 100px;
height: 30px;
background: red;
}
</style>
</head>
<body>
<div id="box"></div>
<script>
window.on