代码
Concentric Circle Coil Animation body { margin: 0; height: 100vh; display: flex; justify-content: center; align-items: center; background-color: #000000; /* Black background for contrast */ } .coil-container { position: relative; width: 300px; height: 300px; } .coil-circle { position: absolute; border: 2px solid white; /* White circles */ border-radius: 50%; opacity: 0; /* Start invisible */ animation: pulse 2s ease-in-out infinite; } @keyframes pulse { 0%, 100% { transform: scale(0); /* Start small */ opacity: 0; /* Fade out */ } 50% { transform: scale(1); /* Scale to full size */ opacity: 1; /* Fade in */ } } const container = document.querySelector('.coil-container'); const numberOfCircles = 20; // Number of concentric circles const baseSize = 30; // Base size for the smallest circle // Create concentric circles for (let i = 0; i < numberOfCircles; i++) { const circle = document.createElement('div'); circle.classList.add('coil-circle'); const size = baseSize + i * 20; // Increase size for each circle circle.style.width = `${size}px`; circle.style.height = `${size}px`; circle.style.top = `50%`; circle.style.left = `50%`; circle.style.marginTop = `-${size / 2}px`; // Center vertically circle.style.marginLeft = `-${size / 2}px`; // Center horizontally circle.style.animationDelay = `${i * 0.2}s`; // Stagger animation container.appendChild(circle); }
登录后复制
以上就是使用 html css js 的线圈错觉的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2664573.html