使用css动画让div元素移动到页面的每个角落

我想知道如何使用css动画使圆形div元素到达页面的每个角落。我试图这样做无济于事。

相当基本的问题,但它会帮助我理解。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS 201</title>
<link href="https://fonts.googleapis.com/css2?family=Pacifico&display=swap" rel="stylesheet">
<style>
  .box {
    width: 300px;
    height: 300px;
    border: 10px solid black;
    background-color: black;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    animation: myAnimation 4s infinite alternate,myAnimation2 4s infinite alternate;
  }
  @keyframes myAnimation {
    0% { top: 0; left: 0; }
    30% { top: 3000px; }
    68%, 72% { left: 50px; }
    100% { top: 3000px; left: 90%; }
  }

  @keyframes myAnimation2{
    0% { bottom: 0; right: 0; }
    30% { top: 3000px; }
    68%, 72% { left: 50px; }
    100% { top: 3000px; left: 90%; }
  }
}
</style>
</head>
<body>
  <div></div>
</body>
</html> 
以上是使用css动画让div元素移动到页面的每个角落的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>