js+css实现曼荼罗花旋转动画效果代码
代码语言:html
所属分类:动画
代码描述:js+css实现曼荼罗花旋转动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { height: 100vh; margin: 0; display: grid; place-items: center; background: radial-gradient(circle, #2e2e2e, #1b1b1b); overflow: hidden; user-select: none; cursor: pointer; } .mandala { position: relative; width: 80vmin; height: 80vmin; opacity: 1; transition: opacity 1s ease-in-out; animation: rotate 20s linear infinite; } .circle { position: absolute; width: var(--size); height: var(--size); background: hsl(calc(var(--hue)), 80%, 60%); border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(calc(var(--angle) * 1deg)) translateY(var(--radius)) rotate(calc(var(--angle) * -1deg)); box-shadow: 0 0 5px rgba(255, 255, 255, 0.5); } @keyframes rotate { to { transform: rotate(360deg); } } </style> </head> <body translate="no"> <div class="mandala"></div> <script > const mandala = document.querySelector('.mandala'); function generateFlowerMandala() { mandala.style.opacity = '0'; // Start fade-out setTimeout(() => { mandala.innerHTML = ''; // Clear existing circles const totalLayers = Math.floor(Math.random() * 8) + 5; // Random layers (5 to 12) const maxRadius = 35; // Maxi.........完整代码请登录后点击上方下载按钮下载查看
网友评论0