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

HTML向四周扩散背景

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>扩散背景效果</title><style>body {margin: 0;height: 100vh;display: flex;justify-content: center;align-items: center;background-color: white;overflow: hidden;}button {padding: 10px 20px;font-size: 16px;cursor: pointer;}#overlay {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0;pointer-events: none;z-index: 100;}#circle {position: fixed;top: 50%;left: 50%;width: 0;height: 0;background-color: black;border-radius: 50%;transform: translate(-50%, -50%);z-index: 101;}</style></head><body><button id="toggleBtn">点击切换背景</button><div id="overlay"></div><div id="circle"></div><script src="script.js"></script></body><script>document.addEventListener("DOMContentLoaded", () => {const toggleBtn = document.getElementById("toggleBtn");const overlay = document.getElementById("overlay");const circle = document.getElementById("circle");let isAnimating = false;toggleBtn.addEventListener("click", () => {if (!isAnimating) {isAnimating = true;// 开始扩散动画let radius = 0;const maxRadius = Math.sqrt(window.innerWidth * window.innerWidth +window.innerHeight * window.innerHeight);const animate = () => {if (radius < maxRadius) {radius += 5;circle.style.width = `${radius * 2}px`;circle.style.height = `${radius * 2}px`;animate();} else {// 扩散完成后,显示黑色背景overlay.style.opacity = "1";circle.style.opacity = "0";isAnimating = false;}};animate();}});});</script>
</html>
http://www.xdnf.cn/news/7220.html

相关文章:

  • Linux-进程间通信
  • Redis有哪些常用应用场景?
  • Kubernetes MCP服务器(K8s MCP):如何使用?
  • upload-labs通关笔记-第12关 文件上传之白名单GET法
  • 【Unity 2023 新版InputSystem系统】新版InputSystem 如何进行人物移动(包括配置、代码详细实现过程)
  • 【软考-架构】15、软件架构的演化和维护
  • 第2篇 水滴穿透:IGBT模块的绝对防御体系
  • NIFI 2.40简介及部署
  • python实现pdf转图片(针对每一页)
  • 手机内存不够,哪些文件可以删?
  • 电气材料的分类及应用
  • MySQL 8.0 OCP 英文题库解析(五)
  • python文件部署docker,容器路径与系统路径映射
  • ionic 列表操作详解
  • 基于vue框架的东莞市二手相机交易管理系统5yz0u(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
  • 解决Windows磁盘管理中因夹卷导致的无法分区问题
  • 146. LRU 缓存
  • 自己拥有一台服务器可以做哪些事情
  • 科技行业智能化升级经典案例—某芯片公司
  • Perl测试管理:从混乱到高效的系统化实践
  • 《DiffPoint训练过程详解:从图像到点云的逐步优化》
  • B树与B+树全面解析
  • Vue3.5 企业级管理系统实战(十九):菜单管理
  • 开发 前端搭建npm v11.4.0 is known not to run on Node.js v14.18.1.
  • Ansible模块——主机名设置和用户/用户组管理
  • 02-前端Web开发(JS+Vue+Ajax)
  • 用Python实现数据库数据自动化导出PDF报告:从MySQL到个性化文档的全流程实践
  • 【工具使用】STM32CubeMX-片内Flash读写操作
  • DTAS 3D多约束装配助力悬架公差分析尺寸链计算:麦弗逊/双叉臂/多连杆/H臂一网打尽
  • 软件设计师“开发过程模型:瀑布、增量、原型、螺旋、喷泉、基于构件的开发模型、形式化方法模型、统一过程RUP、敏捷、极限”真题考点分析——求三连