<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
.ball {
width: 30px;
height: 30px;
background: red;
border-radius: 50%;
position: absolute;
left: 400px;
top: 100px;
}
</style>
</head>
<body>
<div class="ball" id="ball"></div>
<script>
var ball = document.getElementById('ball');
var r = 300;
var deg = 90;
var xposition = ball.offsetLeft + ball.offsetWidth/2;
var yposition = ball.offsetTop + ball.offsetHeight + r;
var circlecenter = {
x:xposition,
y:yposition
}
var timer = setInterval(function(){
ball.style.left = circlecenter.x+r*Math.cos(deg*Math.PI/180)+'px';
ball.style.top = circlecenter.y-r*Math.sin(deg*Math.PI/180)+'px';
deg-=4;
},20)
</script>
</body>
</html>
如图