前端按鈕動畫

效果示例
在這里插入圖片描述

代碼示例

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>按鈕點擊動畫1</title><style>@import url('https://fonts.googleapis.com/css2?family=Pacifico&display=swap');html,body {width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;background-color: #1f1f1f;font-family: 'Pacifico', serif;overflow: hidden;}span {position: relative;display: flex;align-items: center;justify-content: center;flex-grow: 1;}span::after {content: attr(data-text);position: absolute;background-color: #FC4F4F;border-radius: 10px;padding: 6px 20px;font-size: 22px;cursor: pointer;color: #fff;user-select: none;transition: transform 100ms ease-in;}span:active::after {transform: scale(0.9);}@keyframes pumping {50% {transform: scale(0.95);}}.shape {--size: 8px;position: absolute;top: calc(50% - var(--size));left: calc(50% - var(--size));width: calc(var(--size) * 2);height: calc(var(--size) * 2);animation: popup var(--d) cubic-bezier(.08, .56, .53, .98) forwards;}.heart {--size: 6px;background-color: var(--c);}.heart::before,.heart::after {content: "";position: absolute;width: 100%;height: 100%;background-color: var(--c);border-radius: 50%;}.heart::before {left: -50%;}.heart::after {top: -50%;}@keyframes popup {0% {opacity: 0;}60% {opacity: 1;}100% {opacity: 0;transform: translate(var(--x), var(--y)) rotate(var(--r));}}</style>
</head><body><span data-text="Click Me"></span><script>const colors = ['#FC4F4F', '#FFBC80', '#FF9F45', '#F76E11']// const shapes = ['square', 'circle', 'triangle', 'heart']const shapes = ['heart']const randomIntBetween = (min, max) => {return Math.floor(Math.random() * (max - min + 1) + min)}class Particle {constructor({ x, y, rotation, shape, color, size, duration, parent }) {this.x = xthis.y = ythis.parent = parentthis.rotation = rotationthis.shape = shapethis.color = colorthis.size = sizethis.duration = durationthis.children = document.createElement('div')}draw() {this.children.style.setProperty('--x', this.x + 'px')this.children.style.setProperty('--y', this.y + 'px')this.children.style.setProperty('--r', this.rotation + 'deg')this.children.style.setProperty('--c', this.color)this.children.style.setProperty('--size', this.size + 'px')this.children.style.setProperty('--d', this.duration + 'ms')this.children.className = `shape ${this.shape}`this.parent.append(this.children)}animate() {this.draw()const timer = setTimeout(() => {this.parent.removeChild(this.children)clearTimeout(timer)}, this.duration)}}function animateParticles({ total }) {for (let i = 0; i < total; i++) {const particle = new Particle({x: randomIntBetween(-200, 200),y: randomIntBetween(-100, -300),rotation: randomIntBetween(-360 * 5, 360 * 5),shape: shapes[randomIntBetween(0, shapes.length - 1)],color: colors[randomIntBetween(0, colors.length - 1)],size: randomIntBetween(4, 7),duration: randomIntBetween(400, 800),parent})particle.animate()}}const parent = document.querySelector('span')parent.addEventListener("touchstart", () => { }, false);parent.addEventListener('click', e => animateParticles({ total: 40 }))</script>
</body></html>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/717224.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/717224.shtml
英文地址,請注明出處:http://en.pswp.cn/news/717224.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

OSCP靶場--Resourced

OSCP靶場–Resourced 考點(1.rpc枚舉 2.crackmapexec密碼噴灑&#xff0c;hash噴灑 3.ntds.dit system提取域hash 4.基于資源的約束委派攻擊rbcd) 1.nmap掃描 ## ┌──(root?kali)-[~/Desktop] └─# nmap -sV -sC -p- 192.168.188.175 --min-rate 2000 Starting Nmap 7.9…

《一篇文章搞懂git(保姆級教學)》

目錄 1.版本管理工具概念 2. 版本管理工具介紹 2.1版本管理發展簡史(維基百科) 2.1.1 SVN(SubVersion) 2.1.2 Git 3. Git 發展簡史 4. Git 的安裝 4.1 git 的下載 ?4.2 安裝 5. Git 工作流程 5.1 Git 初始化 5.2 git 流程 5.2.1 流程圖 5.2.2概念即詳解 6.Git …

IO多路復用:提高網絡應用性能的利器

&#x1f90d; 前端開發工程師、技術日更博主、已過CET6 &#x1f368; 阿珊和她的貓_CSDN博客專家、23年度博客之星前端領域TOP1 &#x1f560; 牛客高級專題作者、打造專欄《前端面試必備》 、《2024面試高頻手撕題》 &#x1f35a; 藍橋云課簽約作者、上架課程《Vue.js 和 E…

模型部署 - onnx的導出和分析 -(2) - onnx 注冊自定義算子 - 學習記錄

onnx 注冊自定義算子 第一步&#xff1a;手寫一個算子&#xff0c;然后注冊一下第二步&#xff1a;將算子放進模型定義第三步&#xff1a;利用 torch.onnx.export() 編寫onnx 導出函數 一般我們自定義算子的時候&#xff0c;有以下流程 編寫算子并注冊將算子放進模型定義利用 …

unity學習(46)——服務器三次注冊限制以及數據庫化角色信息1--數據流程

1.先找到服務器創建角色信息代碼的位置&#xff0c;UserBizImpl.cs中&#xff1a; public PlayerModel create(string accId, string name, int job) {PlayerModel[] playerModelArray this.list(accId);//list是個自建函數&#xff0c;本質通過accId來查詢if (playerModelAr…

ClickHouse數據引擎

ClickHouse 提供了多種索引引擎&#xff0c;每種引擎都有其特定的用途和特性。除了 MergeTree 引擎之外&#xff0c;以下是一些常見的索引引擎及其區別&#xff1a; MergeTree 引擎&#xff1a; 特點&#xff1a;有序、分布式、支持并發寫入和讀取。適用場景&#xff1a;適用于…

【高數】常數項級數概念與性質

下面為個人數學筆記&#xff0c;有需要借鑒即可。 一、常數項級數概念 二、常數項級數性質 三、調和級數 完。

備忘錄模式(Memento Pattern)

定義 備忘錄模式&#xff08;Memento Pattern&#xff09;是一種行為設計模式&#xff0c;它允許在不破壞封裝性的前提下捕獲一個對象的內部狀態&#xff0c;并在以后將對象恢復到該狀態。備忘錄模式通常用于實現撤銷操作&#xff08;Undo&#xff09;或歷史記錄&#xff08;H…

藍橋杯(3.3)

1208. 翻硬幣 import java.util.Scanner;public class Main {public static void turn(char[] a,int i) {if(a[i] *) a[i] o;else a[i] *;}public static void main(String[] args) {Scanner sc new Scanner(System.in);char[] a sc.next().toCharArray();char[] b sc.n…

python如何設置虛擬環境|方法有哪幾種

原文連接&#xff1a; python設置虛擬環境- Python學習導航 為什么需要虛擬環境&#xff1f; 在使用Python語言時&#xff0c;通過pip&#xff08;pip3&#xff09;來安裝第三方包&#xff0c;但是由于pip的特性&#xff0c;系統中只能安裝每個包的一個版本。但是在實際項目開…

c++之旅——第三彈

大家好啊&#xff0c;這里是c之旅第三彈&#xff0c;跟隨我的步伐來開始這一篇的學習吧&#xff01; 如果有知識性錯誤&#xff0c;歡迎各位指正&#xff01;&#xff01;一起加油&#xff01;&#xff01; 創作不易&#xff0c;希望大家多多支持哦&#xff01; 一.命名空間;…

項目設計:基于Qt和百度AI的車牌識別系統(嵌入式ARM)

基于Qt和百度AI智能云實現的智能車牌識別系統&#xff0c;具體可實現為停車場管理系統、智能計費停車系統…等。 1.系統實現思路及框架 1.1實現思路 要實現一個車牌識別系統&#xff0c;有多種方法&#xff0c;例如用opencv圖像算法實現&#xff0c;或用第三方算法接口&#x…

輸出梯形 C語言

解析&#xff1a;這個輸出圖形的題就是一個找規律加數學計算&#xff0c;我們發現每行比上一行多兩個*&#xff0c;最后一行的*表達式為h&#xff08;h-1&#xff09;*2&#xff0c;即3*h-2&#xff0c;那么每一行就是一個先輸出最后一行&#xff0d;當前行*個數個空格&#xf…

pytorch 圖像數據集管理

目錄 1.數據集的管理說明 2.數據集Dataset類說明 3.圖像分類常用的類 ImageFolder 1.數據集的管理說明 pytorch使用Dataset來管理訓練和測試數據集&#xff0c;前文說過 torchvision.datasets.MNIST 這些 torchvision.datasets里面的數據集都是繼承Dataset而來&#xff0c…

【Qt】QTextEdit/QPlainTextEdit 實現 Tab 鍵多行縮進與反縮進

【Qt】QTextEdit/QPlainTextEdit 實現 Tab 鍵多行縮進與反縮進 文章目錄 I - 主要原理II - 代碼實現2.1 - 自定義類2.2 - 實現 Tab 縮進2.3 - 實現反縮進III - 參考鏈接I - 主要原理 由于 QTextEdit 和 QPlainTextEdit ,都無法實現多行選中縮進與反縮進,選中多行后,按下縮進…

[Redis]——Redis命令手冊set、list、sortedset

&#x1f333;List類型常見命令 LPUSH / RPUSH [KEY] [element] …… 向列表左側或者右側插入一個或多個元素 LPOP / RPOP [key] 刪除左邊或者右邊第一個元素 LRANGE [key] start end 返回索引start到end的元素&#xff08;索引從0開始&#xff09; BLPOP / BRPOP [key] [等…

【C++】類的默認成員函數(上)

&#x1f525;博客主頁&#xff1a; 小羊失眠啦. &#x1f3a5;系列專欄&#xff1a;《C語言》 《數據結構》 《C》 《Linux》 《Cpolar》 ??感謝大家點贊&#x1f44d;收藏?評論?? 文章目錄 一、默認成員函數二、構造函數構造函數的概念及特性 三、析構函數析構函數的特性…

續簡單學生管理系統、包裝類--day18

Day18 一、刪除的思考題 思考題&#xff1a;刪除功能可以省略第一步嗎&#xff1f;不可以 有第一步判斷學生信息合法性&#xff0c;如果信息不合法會直接結束返回 如果沒有第一步&#xff0c;將會在第二步判斷是否有該學生query循環匹配查找&#xff0c;數據量大情況&#xff…

藍橋杯倒計時 43天 - 前綴和,單調棧

最大數組和 算法思路&#xff1a;利用前綴和化簡 for 循環將 n^2 簡化成 nn&#xff0c;以空間換時間。枚舉每個 m&#xff0c;m是刪除最小兩個數&#xff0c;那k-m就是刪除最大數&#xff0c;m<k&#xff0c;求和最大的值。暴力就是枚舉 m-O(n)&#xff0c;計算前 n-(k-m)的…

PCSA時鐘控制集成之時鐘門控級別

這一部分描述了&#xff1a; ? 時鐘門控的級別。 ? 實現最大效果的時鐘門位置。 ? 實現有效和高效時鐘門控的集成方法。 時鐘樹是由時鐘緩沖器構建的&#xff0c;這些緩沖器在時鐘源&#xff08;時鐘輸入或PLL&#xff09;與時鐘終端&#xff08;寄存器或RAM&#xff09…