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: "欢迎进入";
	}

文章来源地址https://uudwc.com/A/59aBA

原文地址:https://blog.csdn.net/qq_41200621/article/details/132319589

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请联系站长进行投诉反馈,一经查实,立即删除!

h
上一篇 2023年09月23日 19:30
Linux安装教程(超详细,含安装文件)
下一篇 2023年09月23日 19:31