分享一个加载按钮动画

先看效果:
在这里插入图片描述
再看代码:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>加载动画按钮</title><script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script><style>* {box-sizing: border-box;}body {width: 100%;height: 100vh;background-color: #000000;font-family: "Plus Jakarta Sans", sans-serif;}body main {display: flex;justify-content: center;align-items: center;width: inherit;height: inherit;}body main .btn-area {position: relative;width: calc(210px + 2px);height: calc(60px + 2px);}body main .btn-area:hover .main-btn {opacity: 0.25;}body main .btn-area .main-btn {width: inherit;height: inherit;opacity: 0.15;transition: 250ms;}body main .btn-area .main-btn rect {width: 210px;height: 60px;transition: 250ms;}body main .btn-area .progress-area,body main .btn-area .complete-area {position: absolute;display: flex;justify-content: space-evenly;align-items: center;top: 50%;left: 50%;transform: translate(-50%, -50%);width: 100%;color: #1578ff;user-select: none;opacity: 1;}body main .btn-area .progress-area .area-left,body main .btn-area .complete-area .area-left {display: flex;}body main .btn-area .progress-area .area-left svg,body main .btn-area .complete-area .area-left svg {margin-right: 1rem;opacity: 0;}body main .btn-area .progress-area .area-left span,body main .btn-area .complete-area .area-left span {width: 50px;text-align: right;}body main .btn-area .progress-area .area-right,body main .btn-area .complete-area .area-right {position: relative;display: flex;align-items: center;height: 20px;margin-right: -1rem;padding-left: 1rem;border-left: 1px solid #1578ff44;overflow: hidden;cursor: pointer;}body main .btn-area .progress-area .area-right:hover,body main .btn-area .complete-area .area-right:hover {height: 40px;transition: 250ms height;}body main .btn-area .progress-area .area-right:hover svg,body main .btn-area .complete-area .area-right:hover svg {opacity: 1;}body main .btn-area .progress-area .area-right svg,body main .btn-area .complete-area .area-right svg {opacity: 0.5;transition: 250ms;}body main .btn-area .progress-area .area-right .btn-play,body main .btn-area .complete-area .area-right .btn-play {position: absolute;transform: translateY(40px);}body main .btn-area .complete-area {justify-content: space-around;display: none;}body main .btn-area .complete-area svg {width: 40px;height: 20px;margin-right: 1rem;padding-right: 1rem;border-right: 1px solid #fff6;}body main .btn-area .complete-area svg path {stroke-linecap: round;stroke-linejoin: round;stroke-width: 6px;opacity: 0;}body main .btn-area .complete-area span {color: #fffd;padding-bottom: 1px;opacity: 0;}body main .btn-area .frame-btn {position: absolute;top: 0;left: 0;width: inherit;height: inherit;}body main .btn-area .frame-btn rect {width: 210px;height: 60px;stroke-linecap: round;stroke-linejoin: round;}body .instagram-link {position: absolute;right: 50px;bottom: 50px;}body .instagram-link i {color: #1578ff;transition: 150ms;font-size: 2rem;opacity: 0.5;}body .instagram-link i:hover {opacity: 1;}</style>
</head>
<body>
<main><div class="btn-area"><svg class="main-btn" xmlns="http://www.w3.org/2000/svg" version="1.1"><rect fill="#fff" stroke="#1578ff" stroke-width="2" x="1" y="1" rx="10" ry="10" /></svg><svg class="frame-btn" xmlns="http://www.w3.org/2000/svg" version="1.1"><rect fill="none" stroke="#1578ff" stroke-width="2" stroke-dasharray="525" stroke-dashoffset="525" x="1" y="1" rx="10" ry="10" /></svg><div class="progress-area"><div class="area-left"><svg width="18" height="18" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 3C17.1 3 16.5 3.6 16.5 4.5V8.25C16.5 9.15 17.1 9.75 18 9.75C18.9 9.75 19.5 9.15 19.5 8.25V4.5C19.5 3.6 18.9 3 18 3Z" fill="#1578ff" /><path d="M10.0504 12.1504C10.3504 12.4504 10.8004 12.6004 11.1004 12.6004C11.4004 12.6004 11.8504 12.4504 12.1504 12.1504C12.7504 11.5504 12.7504 10.6504 12.1504 10.0504L9.45039 7.35039C8.85039 6.75039 7.95039 6.75039 7.35039 7.35039C6.75039 7.95039 6.75039 8.85039 7.35039 9.45039L10.0504 12.1504Z" fill="#1578ff" /><path d="M9.75 18C9.75 17.1 9.15 16.5 8.25 16.5H4.5C3.6 16.5 3 17.1 3 18C3 18.9 3.6 19.5 4.5 19.5H8.25C9 19.5 9.75 18.9 9.75 18Z" fill="#1578ff" /><path d="M10.0508 23.8504L7.50078 26.4004C6.90078 27.0004 6.90078 27.9004 7.50078 28.5004C7.80078 28.8004 8.25078 28.9504 8.55078 28.9504C8.85078 28.9504 9.30078 28.8004 9.60078 28.5004L12.1508 25.9504C12.7508 25.3504 12.7508 24.4504 12.1508 23.8504C11.5508 23.2504 10.6508 23.2504 10.0508 23.8504Z" fill="#1578ff" /><path d="M18 26.25C17.1 26.25 16.5 26.85 16.5 27.75V31.5C16.5 32.4 17.1 33 18 33C18.9 33 19.5 32.4 19.5 31.5V27.75C19.5 27 18.9 26.25 18 26.25Z" fill="#1578ff" /><path d="M25.9504 23.8504C25.3504 23.2504 24.4504 23.2504 23.8504 23.8504C23.2504 24.4504 23.2504 25.3504 23.8504 25.9504L26.4004 28.5004C26.7004 28.8004 27.1504 28.9504 27.4504 28.9504C27.7504 28.9504 28.2004 28.8004 28.5004 28.5004C29.1004 27.9004 29.1004 27.0004 28.5004 26.4004L25.9504 23.8504Z" fill="#1578ff" /><path d="M31.5 16.5H27.75C26.85 16.5 26.25 17.1 26.25 18C26.25 18.9 26.85 19.5 27.75 19.5H31.5C32.4 19.5 33 18.9 33 18C33 17.1 32.4 16.5 31.5 16.5Z" fill="#1578ff" /><path d="M24.9004 12.5998C25.3504 12.5998 25.6504 12.4498 25.9504 12.1498L28.5004 9.5998C29.1004 8.9998 29.1004 8.0998 28.5004 7.4998C27.9004 6.8998 27.0004 6.8998 26.4004 7.4998L23.8504 10.0498C23.2504 10.6498 23.2504 11.5498 23.8504 12.1498C24.1504 12.4498 24.6004 12.5998 24.9004 12.5998Z" fill="#1578ff" /></svg><span>0 %</span></div><div class="area-right"><svg width="18" height="18" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg" class="btn-pause"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.25 6C6.97843 6 6 6.97843 6 8.25V27.75C6 29.0216 6.97843 30 8.25 30H10.65C11.7358 30 12.7805 29.0469 12.9 27.8353V8.25C12.9 6.97843 11.9216 6 10.65 6H8.25ZM3 8.25C3 5.32157 5.32157 3 8.25 3H10.65C13.5784 3 15.9 5.32157 15.9 8.25V27.9C15.9 27.9384 15.8985 27.9768 15.8956 28.015C15.6906 30.6796 13.4492 33 10.65 33H8.25C5.32157 33 3 30.6784 3 27.75V8.25Z" fill="#ff542b" /><path fill-rule="evenodd" clip-rule="evenodd" d="M25.3496 6C24.078 6 23.0996 6.97843 23.0996 8.25V27.75C23.0996 29.0216 24.078 30 25.3496 30H27.7496C29.0613 30 29.9996 28.982 29.9996 27.9V8.25C29.9996 6.97843 29.0212 6 27.7496 6H25.3496ZM20.0996 8.25C20.0996 5.32157 22.4212 3 25.3496 3H27.7496C30.678 3 32.9996 5.32157 32.9996 8.25V27.9C32.9996 30.718 30.6379 33 27.7496 33H25.3496C22.4212 33 20.0996 30.6784 20.0996 27.75V8.25Z" fill="#ff542b" /></svg><svg width="18" height="18" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg" class="btn-play"><path fill-rule="evenodd" clip-rule="evenodd" d="M3 7.33761C3 2.58639 8.08368 0.177285 12.0217 2.27008C12.0446 2.28222 12.0671 2.29495 12.0893 2.30826L30.0453 13.0771C33.9849 15.2998 33.9849 20.6354 30.0453 22.8581L12.0893 33.627L12.0701 33.6383C8.06754 35.9588 3 33.3067 3 28.7474V7.33761ZM10.5822 4.90258C8.33198 3.73209 6 5.21176 6 7.33761V28.7474C6 30.7729 8.36369 32.3115 10.5566 31.048L28.5205 20.2745C28.5334 20.2667 28.5465 20.2591 28.5597 20.2518C30.4801 19.1775 30.4801 16.7578 28.5597 15.6835C28.5521 15.6792 28.5445 15.6749 28.537 15.6705C28.5315 15.6673 28.526 15.6641 28.5205 15.6608L10.5822 4.90258Z" fill="#1578ff" /></svg></div></div><div class="complete-area"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52.71 28.57"><path class="tick-1" fill="none" stroke="#ffff" stroke-dasharray="52" stroke-dashoffset="52" d="M2,12.42,16.14,26.57,34.71,2" /><path class="tick-2" fill="none" stroke="#fff8" stroke-dasharray="52" stroke-dashoffset="52" d="M18,12.42,32.14,26.57,50.71,2" /></svg><span>完毕</span></div></div>
</main></body>
<script>const buttonArea = document.querySelector('.btn-area')const progressArea = document.querySelector('.progress-area')const completeArea = document.querySelector('.complete-area')const mainBtn = document.querySelector('.main-btn rect')const frameBtn = document.querySelector('.frame-btn rect')const loadingIcon = document.querySelector('.progress-area .area-left svg')const loadingProgress = document.querySelector('.progress-area .area-left span')const loadingBtn = document.querySelector('.progress-area .area-right')const pauseBtn = document.querySelector('.progress-area .area-right .btn-pause')const playBtn = document.querySelector('.progress-area .area-right .btn-play')const tick1 = document.querySelector('.complete-area .tick-1')const tick2 = document.querySelector('.complete-area .tick-2')const doneText = document.querySelector('.complete-area span')let loadingTime = 5500let progress = {value: '0 %'}let loadingStatus = truedocument.body.onload = function() {anime({targets: loadingIcon,opacity: [0, 1],duration: 750,easing: 'easeOutQuad'})let aniLoadingIcon = anime({targets: loadingIcon,rotateZ: 360,duration: 2000,loop: true,easing: 'linear'})anime({targets: loadingProgress,translateY: ['15px', '0'],opacity: [0, 1],delay: 250,duration: 750,easing: 'easeOutQuart'})anime({targets: loadingBtn,translateY: ['15px', '0'],opacity: [0, 1],delay: 350,duration: 1000,easing: 'easeOutQuart'})let aniProgress = anime({targets: progress,value: '100 %',duration: loadingTime,easing: 'cubicBezier(.5, .05, .3, .9)',delay: 1000,round: 1,update: function() {loadingProgress.innerHTML = JSON.stringify(progress.value).replace(/^"(.*)"$/, '$1')}})let aniFrameBtn = anime({targets: frameBtn,strokeDashoffset: [525, 0],duration: loadingTime,easing: 'cubicBezier(.5, .05, .3, .9)',delay: 1000,complete: function() {completeLoading()}})loadingBtn.addEventListener('click', () => {if (loadingStatus) {aniLoadingIcon.pause()aniProgress.pause()aniFrameBtn.pause()pauseBtn.style.transform = 'translateY(-40px)'playBtn.style.transform = 'translateY(0px)'loadingStatus = false} else {aniLoadingIcon.play()aniProgress.play()aniFrameBtn.play()pauseBtn.style.transform = 'translateY(0px)'playBtn.style.transform = 'translateY(40px)'loadingStatus = true}})}function completeLoading() {anime({targets: loadingIcon,translateX: [0, -20],opacity: [1, 0],duration: 500,delay: 0,easing: 'easeInQuad'})anime({targets: loadingProgress,translateY: [0, -20],opacity: [1, 0],duration: 500,delay: 250,easing: 'easeInQuad'})anime({targets: loadingBtn,translateY: [0, -20],opacity: [1, 0],duration: 500,delay: 500,easing: 'easeInQuad',complete: function() {progressArea.style.display = 'none'completeArea.style.display = 'flex'}})anime({targets: frameBtn,fill: ['#f5f9fe', '#1578ff'],duration: 500,delay: 750,easing: 'easeInQuad'})anime({targets: tick1,strokeDashoffset: [52, 0],opacity: [0, 1],duration: 500,easing: 'cubicBezier(.5, .05, .3, .9)',delay: 1000})anime({targets: tick2,strokeDashoffset: [52, 0],opacity: [0, 1],duration: 500,easing: 'cubicBezier(.5, .05, .3, .9)',delay: 1250})anime({targets: doneText,opacity: [0, 1],translateY: ['25', '0'],duration: 1000,easing: 'easeOutQuad',delay: 1250})}
</script>
</html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/1287.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

flutter开发实战-卡片翻转动画效果Transform+IndexedStack+rotateAnimation

flutter开发实战-实现卡片翻转动画效果 之前开发中遇到了商品卡片翻转&#xff0c;商品正面是商品图片、商品名称&#xff1b;背面是商品价格&#xff0c;需要做卡片翻转动画。 动画实现即&#xff1a;在一段时间内&#xff0c;快速地多次改变UI外观&#xff1b;由于人眼会产生…

FL Studio是什么软件?FL Studio2023最新更新内容

FL Studio是什么软件 FL Studio是由比利时软件公司Image-Line开发的音乐制作软件&#xff0c;它拥有丰富的音效、合成器、采样器、鼓机等工具。FL Studio支持多种音频文件格式&#xff0c;包括MIDI、MP3、WAV、OGG等&#xff0c;可以帮助用户自由地进行音乐创作。 FL Studio界…

如何有效利用chatgpt?

如何有效地使用ChatGPT&#xff1f; 代码、诗歌、歌曲和短篇小说都可以由 ChatGPT 以特定的风格编写。您所需要的只是正确的问题和适当的提示。以下是有关如何有效使用ChatGPT的一些提示和想法&#xff1a; 头脑 风暴获取初稿解决编码问题尝试不同的提示格式查找标题寻求帮助…

WordPress作为可扩展的企业级解决方案

网络商业世界就像一片汪洋大海&#xff0c;大型企业是大海中最大的鱼。然而&#xff0c;只因为你比其他人都大&#xff0c;并不意味着你不能逆流而上。相反&#xff0c;企业业务面临的挑战更大&#xff0c;对网站的技术要求更高。 多年来&#xff0c;大型公司通常依赖最昂贵的…

Linux总线设备驱动模型

1. 简介 驱动模型中的总线可以是真是存在的物理总线&#xff08;USB总线&#xff0c;I2C总线&#xff0c;PCI总线&#xff09;&#xff0c;也可以是为了驱动模型架构设计出的虚拟总线&#xff08;Platform总线&#xff09;。为此linux设备驱动模型都将围绕"总线–设备–驱…

科普一下Elasticsearch中BM25算法的使用

首先还是先了解几个概念&#xff0c;Elasticsearch是一个开源的分布式搜索和分析引擎&#xff0c;它使用一系列算法来计算文档的相关性分数&#xff08;relevance score&#xff09;。这些算法用于确定查询与文档的匹配程度&#xff0c;以便按相关性对搜索结果进行排序。以下是…

生命在于折腾——MacOS(Inter)渗透测试环境搭建

一、前景提要 之前使用的是2022款M2芯片的MacBook Air 13寸&#xff0c;不得不说&#xff0c;是真的续航好&#xff0c;轻薄&#xff0c;刚开始我了解到M芯片的底层是ARM架构&#xff0c;我觉得可以接受&#xff0c;虚拟机用的不多&#xff0c;但在后续的使用过程中&#xff0…

换零钱II:零钱面值动态变化,class方法自动兑换最少零钱(贪心算法)

银行现存零钱面值种类动态变化但数量无限&#xff0c;类方法change()完成指定金额的最少零钱个数兑换。 (本笔记适合学透python基本数据结构&#xff0c;熟悉class的基构造&#xff0c;对类内全局变量有一定认的 coder 翻阅) 【学习的细节是欢悦的历程】 Python 官网&#xff1…

RabbitMQ消息堆积问题及惰性队列

一&#xff0c;消息堆积 1&#xff0c;消费者堆积问题 当生产者生产消息的速度超过了消费者处理消息的速度&#xff0c;就会导致消息在队列中进行堆积&#xff0c;一定时间后会造成队列达到存储的上限&#xff0c;那么最开始进入队列的消息可能变成死信&#xff0c;会被丢弃&…

【软件测试】Git 详细实战-打标签,一篇通关...

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 Git 打标签 一般会…

dede编辑器修改成纯文本编辑器的方法

我在做优秀啦网站大全的时候需要的正文内容都不需要设置什么文字样式&#xff0c;所以我需要把编辑器上的工具全部取消掉&#xff0c;包括会员投稿中的编辑器工具栏全部取消掉或者屏蔽隐藏掉&#xff0c;所以我需要把DEDE编辑器修改成纯文本编辑器的方法如下&#xff1a;如图&a…

防范 XSS 攻击的措施

防范 XSS 攻击的措施 XSS&#xff08;Cross-site scripting&#xff09;攻击是一种常见的网络安全漏洞&#xff0c;它可以通过注入恶意代码来攻击用户的计算机和浏览器&#xff0c;从而窃取用户的敏感信息或执行恶意操作。本篇文章将介绍防范 XSS 攻击的措施&#xff0c;并提供…

【深度学习论文阅读】四大分类网络之AlexNet

ImageNet Classification with Deep Convolution Nerual Networks 论文原文&#xff1a;ImageNet Classification with Deep Convolutional Neural Networks 1 引言 解决的问题&#xff1a; 提高效率&#xff08;GPU训练&#xff09;&#xff0c;防止过拟合&#xff08;drop…

基于Java的考研教室在线预约系统/基于springboot的考研教室在线预约系统

摘 要 网络的广泛应用给生活带来了十分的便利。所以把考研教室在线预约与现在网络相结合&#xff0c;利用java语言建设考研教室在线预约系统&#xff0c;实现考研教室在线预约的信息化。则对于进一步提高考研教室在线预约发展&#xff0c;丰富考研教室在线预约能起到不少的促进…

语义分割混淆矩阵、 mIoU、mPA计算

一、操作 #vx:桔子code / juzicode.com import cv2 img_gray cv2.imread("nezha.jpg",cv2.IMREAD_GRAYSCALE) for i in range(22):dst cv2.applyColorMap(img_gray,i) cv2.imshow(map,dst) cv2.waitKey(500)cv2.imwrite("map-"str(i)".jpg",…

5G全网通工业三防平板Windows移动电脑

当今科技领域的快速发展为我们的生活带来了许多便利和高效性能。在这个数字化时代&#xff0c;移动设备已成为我们生活的重要组成部分。在这一领域&#xff0c;搭载全新第12代英特尔酷睿Mi5-1235U/i7-1255U处理器的工业三防平板Windows移动电脑无疑是一款引人注目的产品。 这款…

无法找到docker.sock

os环境&#xff1a;麒麟v10(申威) 问题描述&#xff1a; systemctl start docker 然后无法使用docker [rootnode2 ~]# systemctl restart docker [rootnode2 ~]# docker ps Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon r…

vue3使用下载附件功能

效果&#xff1a; 点击即可以下载打开。 代码&#xff1a; <div v-show"item.attachment.length > 0"><h3>下载附件</h3><divv-for"(doc, docIndex) in item.attachment":key"docIndex"><astyle"color: #41…

技术架构的演进-八大架构

目录&#xff1a; 常见概念评价指标单机架构应用数据分离架构应用服务集群架构读写分离 / 主从分离架构引入缓存 —— 冷热分离架构垂直分库业务拆分 —— 微服务容器化引入——容器编排架构总结 1.常见概念&#xff1a; 应用&#xff08;Application&#xff09; / 系统&am…

栈的压入、弹出序列

链接: 栈的压入、弹出序列 class Solution { public:/*** 代码中的类名、方法名、参数名已经指定&#xff0c;请勿修改&#xff0c;直接返回方法规定的值即可** * param pushV int整型vector * param popV int整型vector * return bool布尔型*/bool IsPopOrder(vector<int…