uniapp微信小程序设置开屏启动动画效果

效果预览

 使用uniapp搭建的微信小程序,制作小程序启动开屏动画,主要使用css动画属性。主页代码过多这里就展示重要代码片段。

开屏动画代码
<view v-if="showTransition" :style="{ background: color }" class="card"
			:class="{ active: transitionCompleted }">
			一起听歌Pro
</view>
动画执行完成显示的代码
<view v-else class="pages" :style="{ background: color }">
</view>

js代码

data() {
			return {
				transitionCompleted: false,
				showTransition :true,//
                color:linear-gradient(to top, #fff, #F9F871),
			}
		},
mounted() {
			setTimeout(() => {
				this.transitionCompleted = true;
				setTimeout(() => {
					this.showTransition = false;
				}, 0); // 调整显示过渡页面的时间
			}, 2000); // 调整动画执行的时间
		},

css代码

.card {
		position: relative;
		width: 100%;
		height: 100vh;
		background: mediumturquoise;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 25px;
		font-weight: bold;
		border-radius: 15px;
		cursor: pointer;
	}

	.card::before,
	.card::after {
		position: absolute;
		content: "";
		width: 20%;
		height: 20%;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 25px;
		font-weight: bold;
		background-color: #fff;
		transition: all 2s;
	}

	.card::before {
		top: 0;
		right: 0;
		border-radius: 0 15px 0 100%;
	}

	.card::after {
		bottom: 0;
		left: 0;
		border-radius: 0 100% 0 15px;
	}

	.card::before,
	.card::after {
		width: 100%;
		height: 100%;
		border-radius: 15px;
		animation: expand 2s;
	}

	@keyframes expand {
		0% {
			width: 10%;
			height: 10%;
			border-radius: 15px;
		}

		/*  25% {
	    width: 20%;
	    height: 20%;
	    border-radius: 15px;
	  } */
		100% {
			width: 100%;
			height: 100%;
			border-radius: 15px;
		}
	}

	.card:after {
		content: "欢迎进入";
	}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

源码地址

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值