码迷,mamicode.com
首页 > 移动开发 > 详细

纯JS制作跟随鼠标移动的炫彩气泡,光标动画效果ui

时间:2020-06-12 10:56:19      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:column   info   create   style   events   use   pos   min   splay   

用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

标签:column   info   create   style   events   use   pos   min   splay   

原文地址:https://www.cnblogs.com/023cq/p/13097767.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!