微信小程序太阳落日效果

 主要效果

 

 

 一:wxml

<!--pages/sun/sun.wxml-->
<view class="con">
  <view class="sun"></view>
  <view wx:for="{{box}}" wx:key="index" class="rise" style="bottom:{{160 + 4 * index }}px;animation-delay: {{item.delay}}s;width:{{item.width}}px;height:{{item.height}}px;animation-duration: {{item.duration}}s;"></view>
</view>

二:js

/**
   * 页面的初始数据
   */
  data: {
    box: [],
  },

/**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let box = [];
    for (let i = 0; i < 46; i++) {
      box.push({ name: i })
    }
    box.map(item => {
      item.delay = -Math.random() * 4;
      item.width = 80 + ~~(Math.random() * 100);
      item.height = 8 + ~~(Math.random() * 7);
      item.duration = 3 + Math.random() * 3;
      return item;
    })
    this.setData({
      box,
    })
  },

三:wxss

/* pages/sun/sun.wxss */
page {
  background-color: #000;
  height: 100%;
}

.con {
  position: relative;
  width: 100%;
  height: 90%;
  overflow: hidden;
  filter: contrast(20);
  display: flex;
  justify-content: center;
  margin: 0 auto;
}

.sun {
  position: absolute;
  width: 220px;
  height: 220px;
  bottom: 300px;
  border-radius: 50%;
  background: linear-gradient(#ff7400 50%, #ff7400);
  filter: blur(8px);
}

.sun::after {
  position: absolute;
  content: "";
  left: 10%;
  border-radius: 50%;
  width: 80%;
  height: 65%;
  top: 75%;
  background: #ff8400;
  border: #ff7400 dashed 10px;
}

.rise {
  position: absolute;
  left: -50px;
  bottom: 320px;
  width: 90px;
  height: 13px;
  background: #000;
  animation-name: move;
  animation-iteration-count: infinite;
  filter: blur(5px);
  border-radius: 50%;
  animation-timing-function: ease-in;
}

@keyframes move {
  50% {
    transform: translateX(500rpx);
  }
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值