利用css动画实现*落体效果

主要利用的animation ,关于amimation的效果不再做解释,直接上代码

<!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>Document</title> <style> * { margin: 0; padding: 0; } body { background: #864879; } main { position: absolute; top: 80%; left: 50%; transform: translate(-50%, 0); } .ball { width: 100px; height: 100px; background: radial-gradient(at center, #e67e22, #e74c3c); border-radius: 50%; animation-name: move; animation-duration: 10s; animation-iteration-count: 1; animation-direction: alternate; } .pan { position: absolute; width: 300px; height: 40px; border-radius: 50%; background: rgba(0, 0, 0, 0.3); z-index: -1; filter: blur(5px); transform: translate(-100px, -20px); animation-name: back; animation-duration: 10s; animation-direction: alternate; animation-iteration-count: 1; animation-fill-mode: forwards; } @keyframes back { 0%, 10%, 30%, 50%, 70%, 90% { width: 300px; height: 40px; filter: blur(35px); background: rgba(0, 0, 0, 0.1); } 20%, 40%, 60%, 80%, 100% { width: 300px; height: 40px; filter: blur(5px); background: rgba(0, 0, 0, 0.3); } } @keyframes move { 10% { transform: translateY(-650px); transition: ease-in; } 30% { transform: translateY(-450px); transition: ease-in; } 50% { transform: translateY(-300px); transition: ease-in; } 70% { transform: translateY(-150px); transition: ease-in; } 90% { transform: translateY(-50px); transition: ease-in; }
20%, 40%, 60%, 80%, 100% { transform: translateY(0px); transition: ease-out; } } </style> </head> <body> <main> <div class="ball"></div> <div class="pan"></div> </main> </body> </html> 感兴趣的直接复制跑一下看看效果
上一篇:2021-11-12


下一篇:css中的一些属性