微信小程序animation底部弹窗动画css代码
作者:xlnxin发布时间:2025-02-26分类:编程知识浏览:833
导读:<button catchtap='clickPup'>点击底部动画弹窗</button><!-- 底部弹...
<button catchtap='clickPup'>点击底部动画弹窗</button>
<!-- 底部弹窗动画的内容 -->
<view class='pupContent {{click? "showContent": "hideContent"}} {{option? "open": "close"}}' hover-stop-propagation='true'>
<view class='pupContent-top'>测试一下</view>
</view>
<!-- 固定的背景 -->
<view class='pupContentBG {{click?"showBG":"hideBG"}} {{option?"openBG":"closeBG"}}' catchtap='clickPup'>
</view>wxss代码
.pupContentBG {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
}
.pupContent {
width: 100%;
background: pink;
position: absolute;
bottom: 0;
box-shadow: 0 0 10rpx #333;
height: 0;
z-index: 999;
}
/* 设置显示的背景 */
.showBG {
display: block;
}
.hideBG {
display: none;
}
/* 弹出或关闭动画来动态设置内容高度 */
@keyframes slideBGtUp {
from {
background: transparent;
}
to {
background: rgba(0, 0, 0, 0.1);
}
}
@keyframes slideBGDown {
from {
background: rgba(0, 0, 0, 0.1);
}
to {
background: transparent;
}
}
/* 显示或关闭内容时动画 */
.openBG {
animation: slideBGtUp 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}
.closeBG {
animation: slideBGDown 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}
/* 设置显示内容 */
.showContent {
display: block;
}
.hideContent {
display: none;
}
/* 弹出或关闭动画来动态设置内容高度 */
@keyframes slideContentUp {
from {
height: 0;
}
to {
height: 800rpx;
}
}
@keyframes slideContentDown {
from {
height: 800rpx;
}
to {
height: 0;
}
}
/* 显示或关闭内容时动画 */
.open {
animation: slideContentUp 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}
.close {
animation: slideContentDown 0.5s ease-in both;
/* animation-fill-mode: both 动画将会执行 forwards 和 backwards 执行的动作。 */
}第二种css
/* 弹出或关闭动画来动态设置内容高度 */
@keyframes slideContentUp {
from {
transform: translateY(100%); /*设置为正数则底部弹出来,负数则相反*/
}
to {
transform: translateY(0%);
}
}
@keyframes slideContentDown {
from {
transform: translateY(0%);
}
to {
transform: translateY(100%);
}
}
相关推荐
- EmEditor对小程序wxml设置关键词高亮显示并实现点击块选择提示
- 微信小程序scroll-view实现左右联动上下滚动效果源码
- 新版wxappUnpacker 微信小程序解包实战
- 快来制作个性表情包pk吧
- 微信小程序button如何去掉边框设置透明
- 微信小程序input组件解决iphone拼音字符maxlength长度问题
- 微信小程序弹出对话框输入名字
- 微信小程序页面跳转:wx.switchTab、wx.reLaunch、wx.redirectTo、wx.navigateTo、wx.navigateBack”的使用区别介绍
- 小程序默认icon
- 微信小程序image组件中aspectFill和widthfix、scaleToFill对比
- 编程知识排行
- 最近发表

