CSS 纵向底部往上动画

请添加图片描述

<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>

教学视频地址

点击跳转教学视频

相关推荐

  1. CSS实现从下过渡效果

    2024-01-01 22:20:03       34 阅读
  2. CSS实现从下过渡效果

    2024-01-01 22:20:03       21 阅读
  3. VUE实现纵向动态表格

    2024-01-01 22:20:03       64 阅读
  4. C#数据库传文件

    2024-01-01 22:20:03       22 阅读

最近更新

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

    2024-01-01 22:20:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-01 22:20:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-01 22:20:03       82 阅读
  4. Python语言-面向对象

    2024-01-01 22:20:03       91 阅读

热门阅读

  1. 培养自己的兴趣爱好,没有必要迎合他人。

    2024-01-01 22:20:03       57 阅读
  2. 除了国家自然科学基金,还有以下科研基金

    2024-01-01 22:20:03       60 阅读
  3. 题目 1669: 求圆的面积

    2024-01-01 22:20:03       59 阅读
  4. 编程笔记 html5&css&js 018 HTML颜色

    2024-01-01 22:20:03       61 阅读
  5. vivado 物理约束

    2024-01-01 22:20:03       57 阅读
  6. Linux:20个linux常用命令

    2024-01-01 22:20:03       60 阅读