微信小程序纯css实现一个弹出的菜单

1.实现效果

在这里插入图片描述

2.实现原理

animation动画,transform属性,rotateZ+translate

3.实现代码

<image src="https://i.postimg.cc/Gpm5bmJz/image.png" class="icon {{isShow ? 'a1':'a10'}}"></image>
<image src="https://i.postimg.cc/dVshQb74/image.png" class="icon {{isShow ? 'a2':'a20'}}"></image>
<image src="https://i.postimg.cc/prQdRCRw/image.png" class="icon {{isShow ? 'a3':'a30'}}"></image>
<image src="https://i.postimg.cc/y89F9XfG/add.png" class="icon_new {{isShow ? 'a0' :'a00'}}" catchtap="btnPop"></image>
/* pages/effects/popMenu/index2.wxss */
page {
  background-color: #fff;
}

.icon {
  height: 100rpx;
  width: 100rpx;
  position: absolute;
  bottom: 250rpx;
  right: 100rpx;
  opacity: 0;
}

.icon_new {
  height: 100rpx;
  width: 100rpx;
  position: absolute;
  bottom: 250rpx;
  right: 100rpx;
  z-index: 100;
}

.a0 {
  animation: a0 500ms ease-out forwards;
}

@keyframes a0 {
  0% {
    transform: rotateZ(0deg);
  }

  100% {
    transform: rotateZ(180deg);
  }
}

.a00 {
  animation: a00 500ms ease-out forwards;
}

@keyframes a00 {
  0% {
    transform: rotateZ(180deg);
  }

  100% {
    transform: rotateZ(0deg);
  }

}

.a1 {
  animation: a1 500ms ease-out forwards;
}

@keyframes a1 {
  0% {
    transform: translate(0, 0) rotateZ(0deg);
    opacity: 0;
  }

  100% {
    transform: translate(-65px, -70px) rotateZ(360deg);
    opacity: 1;
  }
}

.a10 {
  animation: a10 500ms ease-out forwards;
}

@keyframes a10 {
  0% {
    transform: translate(-65px, -70px) rotateZ(360deg);
    opacity: 1;
  }

  100% {
    transform: translate(0, 0) rotateZ(0deg);
    opacity: 0;
  }
}

.a2 {
  animation: a2 500ms ease-out forwards;
}

@keyframes a2 {
  0% {
    transform: translate(0, 0) rotateZ(0deg);
    opacity: 0;
  }

  100% {
    transform: translate(-120px, -0px) rotateZ(360deg);
    opacity: 1;
  }
}

.a20 {
  animation: a20 500ms ease-out forwards;
}

@keyframes a20 {
  0% {
    transform: translate(-120px, -0px) rotateZ(360deg);
    opacity: 1;
  }

  100% {
    transform: translate(0, 0) rotateZ(0deg);
    opacity: 0;
  }
}


.a3 {
  animation: a3 500ms ease-out forwards;
}

@keyframes a3 {
  0% {
    transform: translate(0, 0) rotateZ(0deg);
    opacity: 0;
  }

  100% {
    transform: translate(-65px, 70px) rotateZ(360deg);
    opacity: 1;
  }
}

.a30 {
  animation: a30 500ms ease-out forwards;
}

@keyframes a30 {
  0% {
    transform: translate(-65px, 70px) rotateZ(360deg);
    opacity: 1;
  }

  100% {
    transform: translate(0, 0) rotateZ(0deg);
    opacity: 0;
  }

}
Page({
  data: {
    isShow: null,//是否已经弹出
  },
  btnPop() {
    this.setData({
      isShow: !this.data.isShow
    })
  },
})

4.写在最后🍒

看完本文如果觉得有用,记得点赞+关注+收藏鸭 🍕
更多小程序相关,关注🍥苏苏的bug,🍡苏苏的github,🍪苏苏的码云~
  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值