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

CSS3视图过渡动画

概述

网站的主题切换无非就是文字、背景图片或者颜色,我们可以先来看下 Element UI 官网的切换主题的动效:
在这里插入图片描述
PS:Antdesign UI的主题切换动画也是大同小异。

实现的两种方式

CSS 为主

<script setup>
const changeTheme = (e) => {if (document.startViewTransition) {document.startViewTransition(() => {document.documentElement.classList.toggle("dark");});} else {document.documentElement.classList.toggle("dark");}
};onMounted(() => {const target = document.querySelector(".target1");const { x, y } = target.getBoundingClientRect();document.documentElement.style.setProperty("--x", x + "px");document.documentElement.style.setProperty("--y", y + "px");
});
</script>
<style>
::view-transition-old(root) {animation: none;
}
::view-transition-new(root) {mix-blend-mode: normal;animation: clip 1s ease-in;
}@keyframes clip {from {clip-path: circle(0% at var(--x) var(--y));}to {clip-path: circle(100% at var(--x) var(--y));}
}
</style>

<


http://www.mrgr.cn/news/12884.html

相关文章:

  • 树莓派制成的 — 带运动检测和摄像头的安防系统
  • CUDA编程之CUDA Sample-5_Domain_Specific-volumeFiltering(光线追踪)
  • 数据库概述
  • 【Python】读取excel的不同工作簿的内容和获取工作簿的名称
  • 适合运动佩戴的蓝牙耳机推荐?四款开放式运动耳机推荐
  • 如何使用IDEA搭建Mybatis框架环境
  • 交通流量监测检测系统源码分享 # [一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]
  • 【ansible】ansible roles
  • 【JS】使用MessageChannel实现深度克隆
  • 来自OpenAI官网的Function calling介绍与最佳实践
  • 为什么你的RAG不起作用?如何解决语义失调
  • 游戏开发设计模式之桥接模式
  • flutter路由之flutro配置
  • 【Linux篇】三分钟速通Linux基础命令
  • list底层详解
  • 初识C++(8.27)
  • 容器网络-
  • 能大致讲一下Chat GPT的原理吗?
  • ansible的tags标签
  • Kubernetes中的Kube-proxy:服务发现与负载均衡的基石