Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Animated submit buttons
Success state animation
Submit
Error state animation
Submit
* The animation resets for demo purposes
css
* { box-sizing: border-box; } body { padding: 10px; font-size: 16px; font-family: 'Space Mono', sans-serif; text-align: center; background-color: #eaf0ff; color: #002868; } h1 { font-size: 1.5em; } small { color: #888; } @media (min-width: 780px) { .wrapper { width: 600px; display: grid; grid-template-columns: repeat(2, [col] calc(100%/2)); grid-auto-rows: 120px; margin: 30px auto 40px; } } .button { display: inline-block; min-width: 150px; margin: 20px auto; background: #8BC34A; color: #fefefe; font-size: 1.2em; padding: 1em; border-radius: 4px; text-align: center; position: relative; cursor: pointer; appearance: none; -webkit-appearance: none; border: 0; transition: width ease-in 0.15s; } .button:focus { outline: 0; } .button.animate { width: 68.1818181818px; height: 68.1818181818px; min-width: 0; border-radius: 50%; color: transparent; } .button.animate:after { position: absolute; content: ''; width: 25px; height: 25px; border: 4px solid #fefefe; border-radius: 50%; border-left-color: transparent; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); animation: spin ease-in 2.5s forwards; animation-name: spin; -webkit-animation-name: spin; transition-timing-function: ease-in-out; -webkit-transition-timing-function: ease-in-out; animation-duration: 2.5s; -webkit-animation-duration: 2.5s; animation-fill-mode: forwards; -webkit-animation-fill-mode: forwards; } .button.animate.success:before { position: absolute; content: ''; width: 25px; height: 12.5px; border: 4px solid #fefefe; border-right: 0; border-top: 0; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%) rotate(0deg) scale(0); transform: translate(-50%, -50%) rotate(0deg) scale(0); -webkit-animation: success ease-in 0.15s forwards; animation: success ease-in 0.5s forwards; animation-delay: 2.5s; } .button.animate.error { position: relative; -webkit-animation: vibrate ease-in 0.5s forwards; animation: vibrate ease-in 0.5s forwards; -webkit-animation-delay: 2.5s; animation-delay: 2.5s; } .button.animate.error:before { color: #fff; position: absolute; content: '!'; font-size: 1.8rem; font-weight: bold; text-align: center; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0); -webkit-animation: error ease-in 0.5s forwards; animation: error ease-in 0.5s forwards; animation-delay: 2.5s; } @keyframes spin { 0% { transform: translate(-50%, -50%) rotate(0deg) scale(1); } 90% { transform: translate(-50%, -50%) rotate(1080deg) scale(1); } 100% { transform: scale(0); } } @-webkit-keyframes spin { 0% { -webkit-transform: translate(-50%, -50%) rotate(0deg) scale(1); } 98% { -webkit-transform: translate(-50%, -50%) rotate(1080deg) scale(1); } 100% { -webkit-transform: translate(-50%, -50%) rotate(1080deg) scale(0); } } @keyframes success { from { transform: translate(-50%, -50%) rotate(0) scale(0); } to { transform: translate(-50%, -50%) rotate(-45deg) scale(1); } } @-webkit-keyframes success { from { -webkit-transform: translate(-50%, -50%) rotate(0) scale(0); } to { -webkit-transform: translate(-50%, -50%) rotate(-45deg) scale(1); } } @keyframes error { from { transform: translate(-50%, -50%) scale(0); } to { transform: translate(-50%, -50%) scale(1); background-color: #f44336; } } @-webkit-keyframes error { from { -webkit-transform: translate(-50%, -50%) scale(0); } to { -webkit-transform: translate(-50%, -50%) scale(1); background-color: #f44336; } } @keyframes vibrate { 0%, 30%, 60%, 85%, 100% { left: 0; background-color: #f44336; } 10%, 40%, 90%, 70% { left: -2px; background-color: #f44336; } 20%, 50%, 80%, 95% { left: 2px; background-color: #f44336; } }
JavaScript
var animateButton = function(e) { e.preventDefault; //reset animation e.target.classList.remove('animate'); e.target.classList.add('animate'); e.target.classList.add('animate'); setTimeout(function(){ e.target.classList.remove('animate'); },6000); }; var classname = document.getElementsByClassName("button"); for (var i = 0; i < classname.length; i++) { classname[i].addEventListener('click', animateButton, false); }
粒子
时间
文字
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号