微信小程序> 微信小程序顶部提示框弹出动画

微信小程序顶部提示框弹出动画

浏览量:763 时间: 来源:一只愚同学

效果

思路 

参考CSS手册 http://www.w3school.com.cn/css3/css3_animation.asp 

用css的animation属性做动画

代码

wxml:

view class="container"  view class='anit {{show?"show":""}}'请选择商品/view  view bindtap='anniu'点击弹出提示/view/view

wxss:

.container {  height: 100%;  display: flex;  flex-direction: column;  align-items: center;  justify-content: space-between;  padding: 200rpx 0;  box-sizing: border-box;} .anit{  width: 100%;  height: 70rpx;  background: red;  position: absolute;  color: white;  font-size: 30rpx;  line-height: 70rpx;  top: -70rpx;  text-align: center;}.show{  top: -70rpx;  animation: show 2s;  animation-timing-function:ease;}@keyframes show{  0% {top:-70rpx;}  10% {top:0rpx;}  80% {top:0rpx;}  100% {top:-70rpx;}}

js:

Page({  data: {    show: 0  },  onLoad: function () {  },  anniu: function (e) {    if(!this.data.show){      let that = this;      this.setData({        show: 1      })      setTimeout(function () {        that.setData({          show: 0        })      }, 2000)    }  }})

 

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎