纯JS制作跟随鼠标移动的炫彩气泡,光标动画效果ui
Posted 前端分享交流
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了纯JS制作跟随鼠标移动的炫彩气泡,光标动画效果ui相关的知识,希望对你有一定的参考价值。
用js css3制作跟随鼠标悬停网页彩虹泡泡,彩色渐变的气泡光标ui动画特效。
document.addEventListener(\'mousemove\', function(e) { let body = document.querySelector(\'body\'); let circle = document.createElement(\'span\'); let x = e.offsetX; let y = e.offsetY; circle.style.left = x + "px"; circle.style.top = y + "px"; let size = Math.random() * 100; circle.style.width = 20 + size + "px"; circle.style.height = 20 + size + "px"; body.appendChild(circle); setTimeout(function() { circle.remove(); }, 1800); });
* { margin: 0; padding: 0; } body { overflow: hidden; background: #ecf0f3; height: 100vh; } .logo { font-family: "Montserrat", sans-serif; min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; color: #000; font-size: 50px; } span { height: 50px; width: 50px; border-radius: 50%; position: absolute; pointer-events: none; background: #55b9f3; transform: translate(-50%, -50%); animation: blow 4s linear infinite; } @keyframes blow { 0% { transform: translate(-50%, -50%); opacity: 1; filter: hue-rotate(0deg); } 100% { transform: translate(-50%, -1000%); opacity: 0; filter: hue-rotate(720deg); } }
<div class="logo"> 鼠标移动查看演示 </div>
以上是关于纯JS制作跟随鼠标移动的炫彩气泡,光标动画效果ui的主要内容,如果未能解决你的问题,请参考以下文章