当前位置:网站首页>button click animation
button click animation
2022-08-09 02:40:00 【JiuMeilove】
效果示例
代码示例
<!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>button click animation1</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 = x this.y = y this.parent = parent this.rotation = rotation this.shape = shape this.color = color this.size = size this.duration = duration this.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>
边栏推荐
- Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules
- 原文翻译:Structure Aware Single-stage 3D Object Detection from Point Cloud
- Likou Brush Question Record 5.1-----59. Spiral Matrix II
- Solve the Final Fantasy 13-2 Clock Puzzle with DFS
- 【剑指offer65】不适用加减乘除做加法
- 【云计算】XaaS最全介绍(按24字母合集):AaaS、BaaS、CaaS、DaaS、EaaS、FaaS、GaaS、HaaS、IDaaS…
- Take you do interface test from zero to the first case summary
- HMS Core分析服务智能运营6.5.1版本上线
- 如何最大限度地减少企业受到供应链攻击的风险
- 数字 05 verilog&vivado2018.2零散笔记
猜你喜欢

数仓第二篇: 数据模型(维度建模)

Take you do interface test from zero to the first case summary

Jenkins的环境部署,(打包、发布、部署、自动化测试)

Likou Brush Question Record 5.1-----59. Spiral Matrix II

【云计算】XaaS最全介绍(按24字母合集):AaaS、BaaS、CaaS、DaaS、EaaS、FaaS、GaaS、HaaS、IDaaS…

【网络教程】IPtables官方教程--学习笔记3

基于NLP的智能问答系统核心技术

Likou Brush Question Record 1.5-----367. Valid perfect squares

最新工业界推荐系统数据集-召回排序模型原理、结构及代码实战整理分享

第一部分:和数组相关的问题
随机推荐
普通人如何增加收入
What aspects should we start with for interface security testing?
Jenkins配置钉钉通知
【izpack】使用izpack为你的程序提供安装程序封装
Qt 信号槽connect的同步与异步处理
Likou Brush Question Record 1.5-----367. Valid perfect squares
Summary of pytorch related knowledge points
Processing Point Clouds
Open3D 随机采样
科大讯飞笔试题复盘
Likou Brush Question Record 5.1-----59. Spiral Matrix II
MT4 / MQ4L entry to the master of EA tutorial lesson two (2) - - MQL language commonly used function account information commonly used functions
MT4 / MQL4 entry to the master of EA course lesson two - commonly used functions
DataGridView在多线程中出现大红叉
独立机器连接cdh的spark集群,远程提交任务(绝对可以成功,亲测了n遍)
Apache站点下载大文件自动中断或者文件不完整
online schema change and create index
spark RDD转换算子 sample
jmeter的websocket插件安装和使用方法
SQLite切换日志模式优化