CSS 纵向扩展动画

在这里插入图片描述

上干货

<template>
	<!-- @mouseenter="startAnimation" 表示在鼠标进入元素时触发 startAnimation 方法。
	@mouseleave="stopAnimation" 表示在鼠标离开元素时触发 stopAnimation 方法。 -->
	<!-- 容器元素 -->
	<div class="container" @mouseenter="startAnimation" @mouseleave="stopAnimation">
		<!-- 旋转的方块 -->
		<div class="box" :class="{ 'animate': 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;
		/* 定义过渡效果 */
		transition: transform 0.5s;
	}

	/* 应用动画类 */
	.box.animate {
		-webkit-animation: scale-up-tr 0.4s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
			        animation: scale-up-tr 0.4s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
	}

	/* 定义动画 */
	@-webkit-keyframes scale-up-tr {
	  0% {
	    -webkit-transform: scale(0.5);
	            transform: scale(0.5);
	    -webkit-transform-origin: 100% 0%;
	            transform-origin: 100% 0%;
	  }
	  100% {
	    -webkit-transform: scale(1);
	            transform: scale(1);
	    -webkit-transform-origin: 100% 0%;
	            transform-origin: 100% 0%;
	  }
	}
	@keyframes scale-up-tr {
	  0% {
	    -webkit-transform: scale(0.5);
	            transform: scale(0.5);
	    -webkit-transform-origin: 100% 0%;
	            transform-origin: 100% 0%;
	  }
	  100% {
	    -webkit-transform: scale(1);
	            transform: scale(1);
	    -webkit-transform-origin: 100% 0%;
	            transform-origin: 100% 0%;
	  }
	}

</style>

教学视频地址

点击跳转教学视频

相关推荐

  1. VUE实现纵向动态表格

    2023-12-29 06:42:05       65 阅读
  2. 微服务系统设计:横向扩展纵向扩展的对比

    2023-12-29 06:42:05       56 阅读
  3. scss基础和css扩展

    2023-12-29 06:42:05       35 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-29 06:42:05       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-29 06:42:05       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-29 06:42:05       87 阅读
  4. Python语言-面向对象

    2023-12-29 06:42:05       96 阅读

热门阅读

  1. linux/mac 本地环境(使用sshuttle)通过sshd访问k8s内网

    2023-12-29 06:42:05       66 阅读
  2. Jtti:UNIX管道和重定向功能在系统备份中怎么用

    2023-12-29 06:42:05       64 阅读
  3. 阿里云Alibaba Cloud Linux 3.2104 LTS 64位镜像系统介绍

    2023-12-29 06:42:05       58 阅读
  4. 阿里云SSD云盘和ESSD云盘有什么区别?

    2023-12-29 06:42:05       56 阅读
  5. c++——list实现细节反思

    2023-12-29 06:42:05       50 阅读
  6. 【Bootstrap学习 day2】

    2023-12-29 06:42:05       56 阅读
  7. docker基础

    2023-12-29 06:42:05       49 阅读