微信小程序--粘性小球

效果展示

微信小程序--粘性小球.gif

Demo代码

wxml

 <view class="container">
   <view class="big">
    <view class="middle"></view>
    <view class="small"></view>
   </view>
  </view>

wxss

page {
  margin : 0;
  padding: 0;
  background-color:#2c3e50;
  display         : flex;
  justify-content : center;
  align-items     : center;
}

.big {
  position        : relative;
  width           : 340px;
  height          : 340px;
  background-color: #fff;
  border-radius   : 50%;
  display        : flex;
  justify-content: center;
  align-items    : center;
  filter: contrast(1000%);
}

.middle {
  position        : absolute;
  width           : 140px;
  height          : 140px;
  background-color: #000;
  border-radius   : 50%;
  filter          : blur(5px);
}

.small {
  position        : absolute;
  width           : 80px;
  height          : 80px;
  background-color: #f00;
  border-radius   : 50%;
  filter          : blur(5px);
  animation       : move 4s ease-in-out infinite both;
}

@keyframes move {
  0% {
      transform: translateX(-120px);
  }

  10% {
      width : 80px;
      height: 80px;
  }

  17.5% {
      width : 70px;
      height: 100px;
  }

  20% {
      width : 80px;
      height: 80px;
  }

  27.5% {
      width : 80px;
      height: 80px;
  }

  32.5% {
      width : 100px;
      height: 70px;
  }

  37.5% {
      width : 80px;
      height: 80px;
  }

  50% {
      transform: translateX(120px);
  }

  60% {
      width : 80px;
      height: 80px;
  }

  67.5% {
      width : 70px;
      height: 100px;
  }

  70% {
      width : 80px;
      height: 80px;
  }

  77.5% {
      width : 80px;
      height: 80px;
  }

  82.5% {
      width : 100px;
      height: 70px;
  }

  87.5% {
      width : 80px;
      height: 80px;
  }

  100% {
      transform: translateX(-120px);
  }
}

学习于: https://www.bilibili.com/video/BV1bi4y1L7Yt?t=20
在原基础上进行了改动

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容