可直接复制代码运行查看效果
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>基础动画了解</title> </head> <body style="background-color: #000;position: relative;"> <div class="contain"> <div class="ball" id="ball"></div> <div class="pplayout" id="contain"></div> </div> <style type="text/css"> .point{width:1px;height: 1px;border-radius: 50%;overflow: hidden;background:#000;left: 0;top:0;position: absolute;} .contain{background-color: #eee;width: 500px;height: 300px;position: relative;display: block;margin:0 auto;margin-top: 10%;} .pplayout{width: 100%;height: 100%;position: relative;display: block;z-index: 5;} .ball{width:10px;height: 10px;border-radius: 50%;overflow: hidden;box-shadow: 0 0 3px red;background-image: linear-gradient(-90deg, red, yellow);left: -5px;top:295px;position: absolute;z-index: 10;} button{ margin: 5px 0 0 5px; } </style> <div style="margin: 0 auto;width: 500px;"> <button onclick="runAni('Linear')">Linear</button> <button onclick="runAni('Quad.easeIn')">Quad.easeIn</button> <button onclick="runAni('Quad.easeOut')">Quad.easeOut</button> <button onclick="runAni('Quad.easeInOut')">Quad.easeInOut</button> <button onclick="runAni('Cubic.easeIn')">Cubic.easeIn</button> <button onclick="runAni('Cubic.easeOut')">Cubic.easeOut</button> <button onclick="runAni('Cubic.easeInOut')">Cubic.easeInOut</button> <button onclick="runAni('Quart.easeIn')">Quart.easeIn</button> <button onclick="runAni('Quart.easeOut')">Quart.easeOut</button> <button onclick="runAni('Quart.easeInOut')">Quart.easeInOut</button> <button onclick="runAni('Sine.easeIn')">Sine.easeIn</button> <button onclick="runAni('Sine.easeOut')">Sine.easeOut</button> <button onclick="runAni('Sine.easeInOut')">Sine.easeInOut</button> <button onclick="runAni('Expo.easeIn')">Expo.easeIn</button> <button onclick="runAni('Expo.easeOut')">Expo.easeOut</button> <button onclick="runAni('Expo.easeInOut')">Expo.easeInOut</button>