效果
思路
用css的animation屬性做動畫
代碼
wxml:
<view class="container"> <view class='anit {{show == 1?"show":(show == 2?"hide":"")}}'>請選擇商品</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: 0rpx; animation: show 0.2s; animation-timing-function:ease;}@keyframes show{from {top:-70rpx;}to {top:0rpx;}}.hide{ top: -70rpx; animation: hide 0.2s; animation-timing-function:ease;}@keyframes hide{from {top:0rpx;}to {top:-70rpx;}}
js:
Page({ data: { show: 0 }, onLoad: function () { }, anniu:function(e){ let that = this; this.setData({ show:1 }) setTimeout(function () { that.setData({ show: 2 }) }, 2000) }})
總結
以上所述是小編給大家介紹的純CSS實現微信小程序仿QQ頂部提示彈框動畫效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
新聞熱點
疑難解答