CSS 纵向底部往上动画

发布时间:2024年01月01日

请添加图片描述

<template>

	<div class="container" @mouseenter="startAnimation" @mouseleave="stopAnimation">
		<!-- 旋方块 -->
		<div class="box" :class="{ 'scale-up-ver-bottom': isAnimating }">
			<!-- 元素内容 -->
		</div>
	</div>
</template>

<script setup>
	import {
		ref
	} from 'vue';


	const isAnimating = ref(false); // 控制是否应用动画的响应式状态
	function startAnimation() {
		// 鼠标进入容器时,启动动画
		isAnimating.value = true;
	}

	function stopAnimation() {
		// 鼠标离开容器时,停止动画
		isAnimating.value = false;
	}
</script>

<style>
	.container {
		/* 定义容器宽度和高度 */
		width: 100px;
		height: 100px;
		margin-top: 50px;
		margin-left: 40%;
	}

	.box {
		/* 定义方块宽度和高度 */
		width: 100px;
		height: 100px;
		background-color: blue;
	
	}

	.scale-up-ver-bottom {
		-webkit-animation: scale-up-ver-bottom 0.4s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
		        animation: scale-up-ver-bottom 0.4s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
	}
	@-webkit-keyframes scale-up-ver-bottom {
	  0% {
	    -webkit-transform: scaleY(0.4);
	            transform: scaleY(0.4);
	    -webkit-transform-origin: 0% 100%;
	            transform-origin: 0% 100%;
	  }
	  100% {
	    -webkit-transform: scaleY(1);
	            transform: scaleY(1);
	    -webkit-transform-origin: 0% 100%;
	            transform-origin: 0% 100%;
	  }
	}
	@keyframes scale-up-ver-bottom {
	  0% {
	    -webkit-transform: scaleY(0.4);
	            transform: scaleY(0.4);
	    -webkit-transform-origin: 0% 100%;
	            transform-origin: 0% 100%;
	  }
	  100% {
	    -webkit-transform: scaleY(1);
	            transform: scaleY(1);
	    -webkit-transform-origin: 0% 100%;
	            transform-origin: 0% 100%;
	  }
	}

</style>

教学视频地址

点击跳转教学视频

文章来源:https://blog.csdn.net/weixin_54226053/article/details/135325578
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。