js+css实现可鼠标交互的雪景玻璃球动画效果代码
代码语言:html
所属分类:动画
代码描述:js+css实现可鼠标交互的雪景玻璃球动画效果代码,玻璃球中大雪纷飞、路灯一闪一闪的。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { display: grid; place-items: center; grid-template-rows: auto 1fr; height: 100dvh; color: #fff; background-color: black; font-family: monospace; } .snowball-wrapper { position: relative; display: flex; justify-content: center; align-items: center; width: 500px; aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 3px solid #fff; &::after { content: ""; position: absolute; top: 4%; left: 7%; width: 80%; height: 80%; border-radius: 50%; filter: blur(3px); transform: rotateZ(-40deg); pointer-events: none; background: radial-gradient( circle at 50% 80%, rgb(255 255 255 / 0), rgb(255 255 255 / 0) 74%, white 80%, white 84%, rgb(255 255 255 / 0) 100% ); } &::before { content: ""; position: absolute; inset-inline-start: 50%; inset-block-end: 0; background-color: #ffda44; filter: blur(30px); width: 80px; height: 210px; clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%); z-index: -1; animation: blink 10s steps(1) alternate-reverse infinite; } } .snowball-light { position: absolute; inset-block-end: -10px; inset-inline-start: calc(50% - 125px); width: 250px; height: 250px; z-index: -1; } @keyframes blink { 0%, 40%, 60%, 100% { opacity: 1; } 10%, 50%, 90% { opacity: 0; } } </style> </head> <body translate="no"> <h1>Move the cursor over the Snowball</h1> <div class="snowball-wrapper"> <canvas id="snowball" width="500" height="500"></canvas> <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg&.........完整代码请登录后点击上方下载按钮下载查看
网友评论0