Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Submit
css
body{background-color: #282828;overflow: hidden } *{ font-family: 'Roboto'; } .super-container { width: 100vw; height: 100vh; display: flex; justify-content: center; align-items: center; } .container { width: 200px; height: 43px; position: relative; text-align: center; border-radius: 25px; background-color: #D3E5FB; background: linear-gradient( to left, #D3E5FB, #D3E5FB 50%, #4675a8 50%, #3c95fb ); background-position: 90% 0; background-size: 200% 100%; border: 2px solid #3c95fb; pointer-events: all; transition: 0.7s all; } .reset-background { border-radius: 25px; background-color: #D3E5FB; background: linear-gradient( to left, transparent, transparent 50%, #4675a8 50%, #3c95fb ); background-position: 90% 0; background-size: 200% 100%; } .circle { display: flex; justify-content: center; align-items: center; position: absolute; left: 0%; height: 44px; width: 44px; background-color: #3c95fb; border-radius: 50%; box-shadow: 1px 1px 10px grey; transition: 0.7s all; } .text { height: 100%; display: flex; justify-content: center; align-items: center; font-size: 14px; font-weight: 500; color: #3c95fb; user-select: none; } .text-request { color: #D3E5FB; } .request { left: calc(88% - 42px); } .receive { left: calc(100% - 42px); background-color: #4EC10F; transition: 2.7s all; } .failure { left: 0; } .background-request { background-position: 23% 0; user-select: none; pointer-events: none; } .background-receive { background-position: 0 0; background: #daffd9; border-color: #4ABD5D; user-select: none; pointer-events: none; transition: 1.7s all; } .background-failure { background-position: 90% 0; user-select: none; pointer-events: none; transition: 0.7s all; } .text-success { color: #59bf42; } .rotate { -webkit-animation:spin 2s linear infinite; -moz-animation:spin 2s linear infinite; animation:spin 2s linear infinite; transition: 2.7s all; } @-moz-keyframes spin { 100% { -moz-transform: rotate(-360deg); } } @-webkit-keyframes spin { 100% { -webkit-transform: rotate(-360deg); } } @keyframes spin { 100% { -webkit-transform: rotate(-360deg); transform: rotate(-360deg); } }
JavaScript
function init() { updateSVG('init'); } function onClick() { updateSVG('request'); addClass('container', 'background-request'); addClass('circle', 'request'); addClass('text', 'text-request'); changeText('Loading...'); setTimeout(() => { /* Call on request success */ receive(); reset(); }, 2000); // setTimeout(() => { // /* // Call on request failure // */ // failure(); // }, 2000); } /* @description: Methods executed on request success */ function receive(){ updateSVG('receive'); removeClass('container', 'background-request'); addClass('container', 'background-receive'); addClass('circle', 'receive'); addClass('text', 'text-success'); changeText('Success!'); removeClass('text', 'text-request'); } /* @description: Methods executed on request failure */ function failure(){ reset(); } function reset(){ setTimeout(()=>{ removeClass('container', 'background-request'); removeClass('container', 'background-receive'); removeClass('circle', 'request'); removeClass('circle', 'receive'); removeClass('text', 'text-success'); changeText('Submit'); updateSVG('init'); },3000) } /* @utlilty function @description - Adds class to a element */ function addClass(elementId, classname) { var element, name, arr; element = document.getElementById(elementId); name = classname; arr = element.className.split(" "); if (arr.indexOf(name) == -1) { element.className += " " + name; } } /* @utlilty function @description - Removes class to a element */ function removeClass(id, className) { var element = document.getElementById(id); element.classList.remove(className); } function changeText(value){ var text = document.getElementById('text'); text.innerText = value; } function updateSVG(state) { var circle = document.getElementById('circle'); if(state === 'init') { circle.innerHTML = '
' } if(state === 'request') { circle.innerHTML = '
'; } if(state === 'receive') { circle.innerHTML = '
' } }
粒子
时间
文字
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号