Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Your Settings
Edit Personal Info
Set Profile Picture
Change Password
css
@import url("https://fonts.googleapis.com/css?family=Montserrat&display=swap"); html, body { height: 100%; } body { display: flex; align-items: center; justify-content: center; color: white; font-family: "Montserrat"; background-color: #161616; } ul, li { list-style-type: none; } ul { padding-left: 0; font-size: 0.875em; } li { margin: 15px auto; padding: 15px 0px; border-bottom: 1px solid rgba(175, 175, 175, 0.25); } li:last-child { border: none; } a { display: inline-block; text-decoration: none; color: white; display: flex; align-items: center; } h3 { font-size: 20px; } .container { text-align: center; } .menu-btn { border: none; background: linear-gradient(120deg, #f829ab 25%, #f42977 75%, #f41f5f 100%); border-radius: 25px; -webkit-transform: rotate(-45deg) translateZ(0); transform: rotate(-45deg) translateZ(0); width: 70px; height: 70px; position: relative; cursor: pointer; box-shadow: 0px 2px 20px rgba(244, 31, 95, 0.25); margin: 15px auto; } .menu-btn:focus { outline: none; } .menu-btn:before, .menu-btn:after { content: ""; position: absolute; top: calc(50% - 1px); left: calc(50% - 17px); width: 34px; height: 2px; background: white; transition: 0.3s ease all; -webkit-transform: rotate(-45deg) translateZ(0); transform: rotate(-45deg) translateZ(0); } .menu-btn:after { -webkit-transform: rotate(45deg) translateZ(0); transform: rotate(45deg) translateZ(0); } .menu-btn.open:before { -webkit-transform: rotate(0deg); transform: rotate(0deg); } .menu-btn.open:after { -webkit-transform: rotate(90deg); transform: rotate(90deg); } .menu { position: relative; min-height: 250px; min-width: 300px; margin: 15px auto; border-radius: 24px 24px 24px 4px; text-align: left; padding: 15px 20px; -webkit-transform: scale(0); transform: scale(0); -webkit-transform-origin: 50% 50%; transform-origin: 50% 50%; transition: 0.35s ease all; overflow: hidden; } .menu > h3 { opacity: 0; } .menu > ul > li { opacity: 0; } .menu:before { content: ""; position: absolute; top: 0; left: 0; height: 100%; width: 100%; background: #28334b; z-index: -1; border-radius: 50%; -webkit-transform: scale(0.5); transform: scale(0.5); } .menu.active:before { -webkit-animation: 0.2s menuIn 0.15s normal forwards; animation: 0.2s menuIn 0.15s normal forwards; -webkit-animation-timing-function: ease-in; animation-timing-function: ease-in; } .active { -webkit-transform: scale(1); transform: scale(1); } .menu.active > h3 { transition: 0.2s ease-in 0.2s; opacity: 1; } .menu.active > ul > li { transition: 0.2s ease-in 0.2s; opacity: 1; } @-webkit-keyframes menuIn { 0% { -webkit-transform: scale(0.5); transform: scale(0.5); border-radius: 50%; } 45% { -webkit-transform: scale(1.25); transform: scale(1.25); border-radius: 50%; } 100% { -webkit-transform: scale(1); transform: scale(1); border-radius: 24px 24px 24px 4px; } } @keyframes menuIn { 0% { -webkit-transform: scale(0.5); transform: scale(0.5); border-radius: 50%; } 45% { -webkit-transform: scale(1.25); transform: scale(1.25); border-radius: 50%; } 100% { -webkit-transform: scale(1); transform: scale(1); border-radius: 24px 24px 24px 4px; } } @-webkit-keyframes menuOut { from { -webkit-transform: scale(1); transform: scale(1); border-radius: 24px 24px 24px 4px; } to { -webkit-transform: scale(0.5); transform: scale(0.5); border-radius: 50%; } } @keyframes menuOut { from { -webkit-transform: scale(1); transform: scale(1); border-radius: 24px 24px 24px 4px; } to { -webkit-transform: scale(0.5); transform: scale(0.5); border-radius: 50%; } } svg { width: 26px; height: 26px; fill: white; margin-right: 10px; } .menu-btn-container { position: relative; } .menu-btn-pulse { position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0); z-index: -1; width: 80px; height: 80px; border-radius: 50%; border: 1px solid rgba(248, 41, 171, 0.28); -webkit-filter: blur(3px); filter: blur(3px); } .menu-btn-particle { width: 6px; height: 6px; position: absolute; display: inline-block; border-radius: 50%; top: 50%; left: 50%; z-index: -1; }
JavaScript
const randomMinMax = (min,max) => { return min + Math.random() * (max-min); } const button = document.querySelector('.menu-btn'); const menu = document.querySelector('.menu'); const buttonPulse = document.querySelectorAll('.menu-btn-pulse') const btnHoverTl = new TimelineMax({ repeat:-1, paused:true }); btnHoverTl.fromTo(button,0.8,{ scale:1 },{ scale:1.05 }) .to(button,0.6,{ scale:1 }); const pulseTl = new TimelineMax({ repeat:-1, onRepeat:() => { TweenMax.set(buttonPulse,{scale:0.5}) } }); pulseTl.staggerTo(buttonPulse,2,{ scale:2.5, transformOrigin:"center center" },0.25,'in') .staggerTo(buttonPulse,2,{ opacity:0, scale:3.5 },0.25,'in+=0.25'); button.addEventListener('click',() => { menu.classList.toggle('active'); button.classList.toggle('open'); // play particles on click button.classList.contains('open') ? playParticles() : null; if (button.classList.contains('open')) { pulseTl.eventCallback("onRepeat", () => { pulseTl.pause(); }) btnHoverTl.eventCallback('onRepeat',() => { btnHoverTl.pause(); }) } else { pulseTl.eventCallback("onRepeat", null); pulseTl.restart(); btnHoverTl.eventCallback('onRepeat',null) btnHoverTl.restart(); } }); button.addEventListener('mouseover',() => { btnHoverTl.play(); btnHoverTl.eventCallback("onRepeat", null); }); button.addEventListener('mouseleave',()=> { btnHoverTl.eventCallback("onRepeat", () => { btnHoverTl.pause(); }); }); const colors = ["#F829AB","#F42977","#F41F5F"]; const particleCount = 8; const btnContainer = document.querySelector('.menu-btn-container'); // create a few span elements const createParticles = () => { for (let i = 0; i < particleCount; i++) { // create element const particle = document.createElement('span'); // assign class to element particle.setAttribute('class','menu-btn-particle') btnContainer.appendChild(particle); } }; createParticles(); const particle = document.querySelectorAll('.menu-btn-particle'); randomizeParticles = () => { let color = colors[(Math.random() * colors.length) | 0]; TweenMax.set(particle,{x:0,y:0,backgroundColor:() => color }); TweenMax.set(particle,{scale:() => randomMinMax(0.35,1)}); TweenMax.set(particle,{opacity:() => randomMinMax(0.25,1)}); } randomizeParticles(); playParticles = () => { const particleTl = new TimelineMax(); particleTl.staggerTo(particle,0.5,{ cycle: { physics2D: () => { return { velocity:randomMinMax(145,165), angle:randomMinMax(180,325), gravity:randomMinMax(215,225) } } }},'in') .to(particle,0.4,{scale:0,opacity:0,onComplete:() => { randomizeParticles(); }},'in') };
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>粒子按钮动画-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号