当前位置: 首页 > news >正文

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-down-top 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;animation: scale-down-top 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;}/* 定义动画 */@-webkit-keyframes scale-down-top {0% {-webkit-transform: scale(1);transform: scale(1);-webkit-transform-origin: 50% 0%;transform-origin: 50% 0%;}100% {-webkit-transform: scale(0.5);transform: scale(0.5);-webkit-transform-origin: 50% 0%;transform-origin: 50% 0%;}}@keyframes scale-down-top {0% {-webkit-transform: scale(1);transform: scale(1);-webkit-transform-origin: 50% 0%;transform-origin: 50% 0%;}100% {-webkit-transform: scale(0.5);transform: scale(0.5);-webkit-transform-origin: 50% 0%;transform-origin: 50% 0%;}}</style>

### 教学视频地址

[点击跳转教学视频](https://edu.csdn.net/course/detail/39132) 

http://www.lryc.cn/news/271314.html

相关文章:

  • 开源掌机是什么?
  • 基于Wenet长音频分割降噪识别
  • mysql基础-表操作
  • MySql——1146 - Table‘mysql.proc‘doesn‘t exit是这个
  • 玩转贝启科技BQ3588C开源鸿蒙系统开发板 —— 代码下载(1)
  • 开源预约挂号平台 - 从0到上线
  • Vue3的proxy
  • Vue Router的介绍与引入
  • StratifiedKFold解释和代码实现
  • 四十八----react实战
  • 三步实现Java的SM2前端加密后端解密
  • 1分钟带你了解golang(go语言)
  • CSS-4
  • Python为何适合开发AI项目?
  • 总结心得:各设计模式使用场景
  • 详解Vue3中的事件监听方式
  • Unity关于easySave2 easySave3保存数据的操作;包含EasySave3运行报错的解决
  • 2022年全球软件质量效能大会(QECon上海站)-核心PPT资料下载
  • 【python报错】UserWarning: train_labels has been renamed targets
  • 算法专题四:前缀和
  • STM32学习笔记十五:WS2812制作像素游戏屏-飞行射击游戏(5)探索动画之帧动画
  • 期末复习(程序设计)
  • html-css-js移动端导航栏底部固定+i18n国际化全局
  • Ubuntu Linux 入门指南:面向初学者
  • 常见算法面试题目
  • PiflowX组件-JDBCWrite
  • 算法导论复习题目
  • HTTPS协议详解
  • 菜鸟学习vue3笔记-vue3 router回顾
  • Mybatis枚举类型处理和类型处理器